Class: Comfy::Admin::Cms::SnippetsController
- Inherits:
-
BaseController
- Object
- BaseController
- Comfy::Admin::Cms::SnippetsController
- Includes:
- ReorderAction
- Defined in:
- app/controllers/comfy/admin/cms/snippets_controller.rb
Instance Method Summary collapse
Methods included from ReorderAction
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/controllers/comfy/admin/cms/snippets_controller.rb', line 25 def create @snippet.save! flash[:success] = I18n.t("comfy.admin.cms.snippets.created") redirect_to action: :edit, id: @snippet rescue ActiveRecord::RecordInvalid flash.now[:danger] = I18n.t("comfy.admin.cms.snippets.creation_failure") render action: :new end |
#destroy ⇒ Object
43 44 45 46 47 |
# File 'app/controllers/comfy/admin/cms/snippets_controller.rb', line 43 def destroy @snippet.destroy flash[:success] = I18n.t("comfy.admin.cms.snippets.deleted") redirect_to action: :index end |
#edit ⇒ Object
21 22 23 |
# File 'app/controllers/comfy/admin/cms/snippets_controller.rb', line 21 def edit @snippet.attributes = snippet_params end |
#index ⇒ Object
12 13 14 15 |
# File 'app/controllers/comfy/admin/cms/snippets_controller.rb', line 12 def index return redirect_to action: :new if @site.snippets.count.zero? @snippets = @site.snippets.includes(:categories).for_category(params[:categories]).order(:position) end |
#new ⇒ Object
17 18 19 |
# File 'app/controllers/comfy/admin/cms/snippets_controller.rb', line 17 def new render end |
#update ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/controllers/comfy/admin/cms/snippets_controller.rb', line 34 def update @snippet.update!(snippet_params) flash[:success] = I18n.t("comfy.admin.cms.snippets.updated") redirect_to action: :edit, id: @snippet rescue ActiveRecord::RecordInvalid flash.now[:danger] = I18n.t("comfy.admin.cms.snippets.update_failure") render action: :edit end |