Class: Cms::LinksController

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

Instance Method Summary collapse

Methods inherited from BaseController

allow_guests_to

Methods inherited from ApplicationController

#no_browser_caching

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/cms/links_controller.rb', line 26

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

#destroyObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/cms/links_controller.rb', line 46

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



22
23
24
# File 'app/controllers/cms/links_controller.rb', line 22

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

#resourceObject



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

def resource
  @link
end

#resource_paramObject



14
15
16
# File 'app/controllers/cms/links_controller.rb', line 14

def resource_param
  :link
end

#showObject



18
19
20
# File 'app/controllers/cms/links_controller.rb', line 18

def show
  redirect_to sitemap_path
end

#updateObject



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

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