Class: CmsAdmin::TabsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/cms_admin/tabs_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



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

#editObject



16
17
18
# File 'app/controllers/cms_admin/tabs_controller.rb', line 16

def edit
  render
end

#indexObject



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

#newObject



12
13
14
# File 'app/controllers/cms_admin/tabs_controller.rb', line 12

def new
  render
end

#reorderObject



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

#updateObject



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