Class: Cms::LinksController

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

Instance Method Summary collapse

Methods included from PageHelper

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

Methods included from PathHelper

#cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #edit_cms_connectable_path

Methods included from ErrorHandling

#handle_access_denied, #handle_server_error, included

Instance Method Details

#createObject



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

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

#destroyObject



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

def destroy
  respond_to do |format|
    if @link.destroy
      message = "Link '#{@link.name}' was deleted."
      format.html { flash[:notice] = message; redirect_to(cms_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(cms_sitemap_url) }
      format.json { render :json => {:success => false, :message => message } }
    end
  end    
end

#newObject



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

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

#updateObject



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

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