Class: CmsAdmin::MenuItemsController
- Inherits:
-
BaseController
- Object
- BaseController
- CmsAdmin::MenuItemsController
- Defined in:
- app/controllers/cms_admin/menu_items_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #reorder ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/cms_admin/menu_items_controller.rb', line 19 def create @menu_item.save! flash[:success] = I18n.t('cms.menu_items.created') redirect_to :action => :index rescue ActiveRecord::RecordInvalid logger.detailed_error($!) flash.now[:error] = I18n.t('cms.menu_items.creation_failure') render :action => :new end |
#destroy ⇒ Object
39 40 41 42 43 |
# File 'app/controllers/cms_admin/menu_items_controller.rb', line 39 def destroy @menu_item.destroy flash[:success] = I18n.t('cms.menu_items.deleted') redirect_to :action => :index end |
#edit ⇒ Object
15 16 17 |
# File 'app/controllers/cms_admin/menu_items_controller.rb', line 15 def edit render end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/cms_admin/menu_items_controller.rb', line 6 def index return redirect_to :action => :new if @menu..count == 0 @menu_items = @menu. end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/cms_admin/menu_items_controller.rb', line 11 def new render end |
#reorder ⇒ Object
45 46 47 48 49 50 |
# File 'app/controllers/cms_admin/menu_items_controller.rb', line 45 def reorder (params[:cms_menu_item] || []).each_with_index do |id, index| Cms::MenuItem.where(:id => id).update_all(:position => index) end render :nothing => true end |
#update ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/cms_admin/menu_items_controller.rb', line 29 def update @menu_item.update_attributes!(params[:menu_item]) flash[:success] = I18n.t('cms.menu_items.updated') redirect_to :action => :index, :id => @menu_item rescue ActiveRecord::RecordInvalid logger.detailed_error($!) flash.now[:error] = I18n.t('cms.menu_items.update_failure') render :action => :edit end |