Class: CmsAdmin::TabsController
- Inherits:
-
BaseController
- Object
- BaseController
- CmsAdmin::TabsController
- Defined in:
- app/controllers/cms_admin/tabs_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
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/cms_admin/tabs_controller.rb', line 20 def create @tab.save! flash[:success] = I18n.t('cms.tabs.created') redirect_to :action => :index rescue ActiveRecord::RecordInvalid logger.detailed_error($!) flash.now[:error] = I18n.t('cms.tabs.creation_failure') render :action => :new end |
#destroy ⇒ Object
40 41 42 43 44 |
# File 'app/controllers/cms_admin/tabs_controller.rb', line 40 def destroy @tab.destroy flash[:success] = I18n.t('cms.tabs.deleted') redirect_to :action => :index end |
#edit ⇒ Object
16 17 18 |
# File 'app/controllers/cms_admin/tabs_controller.rb', line 16 def edit render end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/cms_admin/tabs_controller.rb', line 7 def index return redirect_to :action => :new if @site.tabs.count == 0 @tabs = @page.tabs end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/cms_admin/tabs_controller.rb', line 12 def new render end |
#reorder ⇒ Object
46 47 48 49 50 51 |
# File 'app/controllers/cms_admin/tabs_controller.rb', line 46 def reorder (params[:cms_tab] || []).each_with_index do |id, index| Cms::Tab.where(:id => id).update_all(:position => index) end render :nothing => true end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/cms_admin/tabs_controller.rb', line 30 def update @tab.update_attributes!(params[:tab]) flash[:success] = I18n.t('cms.tabs.updated') redirect_to :action => :edit, :id => @tab rescue ActiveRecord::RecordInvalid logger.detailed_error($!) flash.now[:error] = I18n.t('cms.tabs.update_failure') render :action => :edit end |