Sha256: 59cd7cd793766721e33c8bafd8992e7f1f19b327b6c0914e6946e6941bdb5cd1
Contents?: true
Size: 1.21 KB
Versions: 28
Compression:
Stored size: 1.21 KB
Contents
module Cms class PageRouteOptionsController < Cms::BaseController before_filter :load_page_route before_filter :load_model, :only => [:edit, :update, :destroy] def new @model = resource.new end def create @model = resource.new(params[object_name]) if @model.save flash[:notice] = "#{object_name.titleize} added" redirect_to cms_page_route_url(@page_route) else render :action => "new" end end def update if @model.update_attributes(params[object_name]) flash[:notice] = "#{object_name.titleize} updated" redirect_to cms_page_route_url(@page_route) else render :action => "edit" end end def destroy @model.destroy flash[:notice] = "#{object_name.titleize} deleted" redirect_to cms_page_route_url(@page_route) end protected def load_page_route @page_route end def load_model @model = resource.find(params[:id]) end def resource @page_route.send(resource_name.pluralize) end def resource_name self.class.name.match(/Cms::PageRoute(\w+)Controller/)[1].downcase.singularize end def object_name "page_route_#{resource_name}" end end end
Version data entries
28 entries across 28 versions & 2 rubygems