Class | Cms::DynamicViewsController |
In: |
app/controllers/cms/dynamic_views_controller.rb
|
Parent: | Cms::BaseController |
# File app/controllers/cms/dynamic_views_controller.rb, line 19 19: def create 20: @view = dynamic_view_type.new(params[dynamic_view_type.name.underscore]) 21: if @view.save 22: flash[:notice] = "#{dynamic_view_type} '#{@view.name}' was created" 23: redirect_to cms_index_path_for(dynamic_view_type.name.underscore.pluralize) 24: else 25: render :action => "new" 26: end 27: end
# File app/controllers/cms/dynamic_views_controller.rb, line 42 42: def destroy 43: @view.destroy 44: flash[:notice] = "#{dynamic_view_type} '#{@view.name}' was deleted" 45: redirect_to cms_index_path_for(dynamic_view_type.name.underscore.pluralize) 46: end
# File app/controllers/cms/dynamic_views_controller.rb, line 11 11: def index 12: @views = dynamic_view_type.paginate(:page => params[:page], :order => "name") 13: end
# File app/controllers/cms/dynamic_views_controller.rb, line 15 15: def new 16: @view = dynamic_view_type.new_with_defaults 17: end
# File app/controllers/cms/dynamic_views_controller.rb, line 29 29: def show 30: redirect_to [:edit, :cms, @view] 31: end
# File app/controllers/cms/dynamic_views_controller.rb, line 33 33: def update 34: if @view.update_attributes(params[dynamic_view_type.name.underscore]) 35: flash[:notice] = "#{dynamic_view_type} '#{@view.name}' was updated" 36: redirect_to cms_index_path_for(dynamic_view_type.name.underscore.pluralize) 37: else 38: render :action => "edit" 39: end 40: end
# File app/controllers/cms/dynamic_views_controller.rb, line 49 49: def dynamic_view_type 50: @dynamic_view_type ||= begin 51: type = request.request_uri.split('/')[2].classify.constantize 52: raise "Invalid Type" unless type.ancestors.include?(DynamicView) 53: type 54: end 55: end
# File app/controllers/cms/dynamic_views_controller.rb, line 61 61: def load_view 62: @view = dynamic_view_type.find(params[:id]) 63: end