Sha256: 501032eb3c3b0a813e21b5456ffac3a623774c6d67622aa03146b6499f8db1b7

Contents?: true

Size: 1.2 KB

Versions: 38

Compression:

Stored size: 1.2 KB

Contents

class Cms::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

Version data entries

38 entries across 38 versions & 10 rubygems

Version Path
SFEley-browsercms-3.0.2 app/controllers/cms/page_route_options_controller.rb
buzzware-browsercms-3.0.2 app/controllers/cms/page_route_options_controller.rb
coredumplings-browsercms-3.0.0 app/controllers/cms/page_route_options_controller.rb
nate-browsercms-3.0.210 app/controllers/cms/page_route_options_controller.rb
nate-browsercms-3.0.211 app/controllers/cms/page_route_options_controller.rb
we5-browsercms-3.0.1.1 app/controllers/cms/page_route_options_controller.rb
webficient-browsercms-3.0.1 app/controllers/cms/page_route_options_controller.rb
webficient-browsercms-3.0.2 app/controllers/cms/page_route_options_controller.rb
webficient-browsercms-3.0.3 app/controllers/cms/page_route_options_controller.rb
webficient-browsercms-3.0.4 app/controllers/cms/page_route_options_controller.rb
browsercms-3.3.4 app/controllers/cms/page_route_options_controller.rb
browsercms-3.3.3 app/controllers/cms/page_route_options_controller.rb
browsercms-3.1.5 app/controllers/cms/page_route_options_controller.rb
browsercms-3.1.4 app/controllers/cms/page_route_options_controller.rb
browsercms-3.3.2 app/controllers/cms/page_route_options_controller.rb
browsercms-3.3.1 app/controllers/cms/page_route_options_controller.rb
browsercms-3.3.0 app/controllers/cms/page_route_options_controller.rb
browsercms-3.1.3 app/controllers/cms/page_route_options_controller.rb
browsercms-3.3.0.beta app/controllers/cms/page_route_options_controller.rb
bf4-browsercms-3.1.0 app/controllers/cms/page_route_options_controller.rb