Sha256: 4f65504d1b9372beaedfe2e7d520149900e7e232355233afd8de314bed7a5b90
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
class CmsAdmin::TabsController < CmsAdmin::BaseController before_filter :build_tab, :only => [:new, :create] before_filter :load_tab, :only => [:edit, :update, :destroy] before_filter :load_page, :only => [:index] def index return redirect_to :action => :new if @site.tabs.count == 0 @tabs = @page.tabs end def new render end def edit render end 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 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 def destroy @tab.destroy flash[:success] = I18n.t('cms.tabs.deleted') redirect_to :action => :index end 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 protected def load_page @page = @site.pages.find(params[:page_id]) end def build_tab load_page @tab = @page.tabs.new(params[:tab]) end def load_tab load_page @tab = @page.tabs.find(params[:id]) rescue ActiveRecord::RecordNotFound flash[:error] = I18n.t('cms.tabs.not_found') redirect_to :action => :index end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comfypress-0.1.4 | app/controllers/cms_admin/tabs_controller.rb |