Class: Cms::LinksController
Instance Method Summary
collapse
Methods included from PageHelper
#able_to?, #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
#handle_access_denied, #handle_server_error, included
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
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
|
#new ⇒ Object
8
9
10
|
# File 'app/controllers/cms/links_controller.rb', line 8
def new
@link = Link.new(:section => @section)
end
|
#update ⇒ Object
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
|