Class: Cms::LinksController

Inherits:
BaseController show all
Defined in:
app/controllers/cms/links_controller.rb

Instance Method Summary collapse

Methods included from PageHelper

#able_to?, #cms_content_editor, #cms_toolbar, #container, #container_has_block?, #current_page, #page_title, #render_breadcrumbs, #render_portlet

Methods included from PathHelper

#attachment_path_for, #cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #cms_sortable_column_path, #edit_cms_connectable_path, #engine_for, #link_to_usages, #path_elements_for

Methods included from ErrorHandling

#handle_access_denied, #handle_server_error, #with_format

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/cms/links_controller.rb', line 13

def create
  @link = Link.new(params[:link])
  @link.section = @section
  if @link.save
    flash[:notice] = "Link was '#{@link.name}' created."
    redirect_to @section
  else
    render :action => "new"
  end
end

#destroyObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/cms/links_controller.rb', line 33

def destroy
  respond_to do |format|
    if @link.destroy
      message = "Link '#{@link.name}' was deleted."
      format.html { flash[:notice] = message; redirect_to(sitemap_url) }
      format.json { render :json => {:success => true, :message => message } }
    else
      message = "Link '#{@link.name}' could not be deleted"
      format.html { flash[:error] = message; redirect_to(sitemap_url) }
      format.json { render :json => {:success => false, :message => message } }
    end
  end    
end

#newObject



9
10
11
# File 'app/controllers/cms/links_controller.rb', line 9

def new
  @link = Link.new(:section => @section)
end

#updateObject



24
25
26
27
28
29
30
31
# File 'app/controllers/cms/links_controller.rb', line 24

def update
  if @link.update_attributes(params[:link])
    flash[:notice] = "Link '#{@link.name}' was updated"
    redirect_to @link.section
  else
    render :action => 'edit'
  end      
end