Sha256: 2c8f4af94715d08cd7a962df27946bcbcdc69925df1f8a1714d7a0c511a911be

Contents?: true

Size: 703 Bytes

Versions: 6

Compression:

Stored size: 703 Bytes

Contents

class E9Crm::MenuOptionsController < E9Crm::ResourcesController
  defaults :resource_class => MenuOption
  include E9Rails::Controllers::Sortable

  has_scope :options_for, :as => :key, :only => :index

  # NOTE The reason this is set in a filter instead of just a default scope value 
  #      is that it is used in the index view to add the key param to the new 
  #      resource link
  #
  before_filter :ensure_default_fetch_key, :only => :index

  def create
    create! { collection_path(:key => resource.key) }
  end

  def update
    update! { collection_path(:key => resource.key) }
  end

  protected

  def ensure_default_fetch_key
    params[:key] ||= MenuOption::KEYS.sort.first
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
e9_crm-0.1.8 app/controllers/e9_crm/menu_options_controller.rb
e9_crm-0.1.7 app/controllers/e9_crm/menu_options_controller.rb
e9_crm-0.1.6 app/controllers/e9_crm/menu_options_controller.rb
e9_crm-0.1.5 app/controllers/e9_crm/menu_options_controller.rb
e9_crm-0.1.4 app/controllers/e9_crm/menu_options_controller.rb
e9_crm-0.1.1 app/controllers/e9_crm/menu_options_controller.rb