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

Version Path
browsercms-artirix-4.0.4 app/controllers/cms/page_route_options_controller.rb
browsercms-artirix-4.0.3.3 app/controllers/cms/page_route_options_controller.rb
browsercms-artirix-4.0.3.2 app/controllers/cms/page_route_options_controller.rb
browsercms-artirix-4.0.3.1 app/controllers/cms/page_route_options_controller.rb
browsercms-artirix-4.0.3 app/controllers/cms/page_route_options_controller.rb
browsercms-artirix-4.0.2 app/controllers/cms/page_route_options_controller.rb
browsercms-artirix-4.0.1.1 app/controllers/cms/page_route_options_controller.rb
browsercms-artirix-4.0.0.rc1.art4 app/controllers/cms/page_route_options_controller.rb
browsercms-4.0.0.rc1 app/controllers/cms/page_route_options_controller.rb
browsercms-4.0.0.beta app/controllers/cms/page_route_options_controller.rb
browsercms-4.0.0.alpha app/controllers/cms/page_route_options_controller.rb
browsercms-3.5.7 app/controllers/cms/page_route_options_controller.rb
browsercms-3.5.6 app/controllers/cms/page_route_options_controller.rb
browsercms-3.5.5 app/controllers/cms/page_route_options_controller.rb
browsercms-3.5.4 app/controllers/cms/page_route_options_controller.rb
browsercms-3.5.3 app/controllers/cms/page_route_options_controller.rb
browsercms-3.5.2 app/controllers/cms/page_route_options_controller.rb
browsercms-3.5.1 app/controllers/cms/page_route_options_controller.rb
browsercms-3.5.0 app/controllers/cms/page_route_options_controller.rb
browsercms-3.5.0.rc3 app/controllers/cms/page_route_options_controller.rb