Sha256: edfcd4c789f1b30c575732d019988352523700b863960841cbe49e62333084c3

Contents?: true

Size: 790 Bytes

Versions: 5

Compression:

Stored size: 790 Bytes

Contents

class E9Attributes::MenuOptionsController < Admin::ResourceController
  include E9Rails::Controllers::Sortable
  include E9Rails::Helpers::ResourceLinks

  respond_to :js

  defaults :resource_class => MenuOption, :route_prefix => nil
  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

5 entries across 5 versions & 1 rubygems

Version Path
e9_attributes-0.0.6 app/controllers/e9_attributes/menu_options_controller.rb
e9_attributes-0.0.5 app/controllers/e9_attributes/menu_options_controller.rb
e9_attributes-0.0.4 app/controllers/e9_attributes/menu_options_controller.rb
e9_attributes-0.0.3 app/controllers/e9_attributes/menu_options_controller.rb
e9_attributes-0.0.2 app/controllers/e9_attributes/menu_options_controller.rb