Sha256: e6adf11d5c6806910b18b6dc912938e8a3fcdf800002c8f66b1fa94ef3598d3f
Contents?: true
Size: 1.37 KB
Versions: 23
Compression:
Stored size: 1.37 KB
Contents
class CmsAdmin::SnippetsController < CmsAdmin::BaseController before_filter :build_snippet, :only => [:new, :create] before_filter :load_snippet, :only => [:edit, :update, :destroy] def index return redirect_to :action => :new if @site.snippets.count == 0 @snippets = @site.snippets.for_category(params[:category]).all(:order => 'label') end def new render end def edit render end def create @snippet.save! flash[:notice] = I18n.t('cms.snippets.created') redirect_to :action => :edit, :id => @snippet rescue ActiveRecord::RecordInvalid flash.now[:error] = I18n.t('cms.snippets.creation_failure') render :action => :new end def update @snippet.update_attributes!(params[:snippet]) flash[:notice] = I18n.t('cms.snippets.updated') redirect_to :action => :edit, :id => @snippet rescue ActiveRecord::RecordInvalid flash.now[:error] = I18n.t('cms.snippets.update_failure') render :action => :edit end def destroy @snippet.destroy flash[:notice] = I18n.t('cms.snippets.deleted') redirect_to :action => :index end protected def build_snippet @snippet = @site.snippets.new(params[:snippet]) end def load_snippet @snippet = @site.snippets.find(params[:id]) rescue ActiveRecord::RecordNotFound flash[:error] = I18n.t('cms.snippets.not_found') redirect_to :action => :index end end
Version data entries
23 entries across 23 versions & 1 rubygems