Class: Cms::DynamicViewsController

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

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

Methods included from ErrorHandling

#handle_access_denied, #handle_server_error, included

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/cms/dynamic_views_controller.rb', line 19

def create
  @view = dynamic_view_type.new(params[dynamic_view_type.name.underscore])
  if @view.save
    flash[:notice] = "#{dynamic_view_type} '#{@view.name}' was created"
    redirect_to cms_index_path_for(dynamic_view_type.name.underscore.pluralize)
  else
    render :action => "new"
  end
end

#destroyObject



42
43
44
45
46
# File 'app/controllers/cms/dynamic_views_controller.rb', line 42

def destroy
  @view.destroy
  flash[:notice] = "#{dynamic_view_type} '#{@view.name}' was deleted"
  redirect_to cms_index_path_for(dynamic_view_type.name.underscore.pluralize)    
end

#indexObject



11
12
13
# File 'app/controllers/cms/dynamic_views_controller.rb', line 11

def index
  @views = dynamic_view_type.paginate(:page => params[:page], :order => "name")
end

#newObject



15
16
17
# File 'app/controllers/cms/dynamic_views_controller.rb', line 15

def new
  @view = dynamic_view_type.new_with_defaults
end

#showObject



29
30
31
# File 'app/controllers/cms/dynamic_views_controller.rb', line 29

def show
  redirect_to [:edit, :cms, @view]
end

#updateObject



33
34
35
36
37
38
39
40
# File 'app/controllers/cms/dynamic_views_controller.rb', line 33

def update
  if @view.update_attributes(params[dynamic_view_type.name.underscore])
    flash[:notice] = "#{dynamic_view_type} '#{@view.name}' was updated"
    redirect_to cms_index_path_for(dynamic_view_type.name.underscore.pluralize)
  else
    render :action => "edit"
  end
end