Class: CamaleonCms::Admin::PostTagsController
- Inherits:
-
CamaleonCms::AdminController
- Object
- CamaleonCms::AdminController
- CamaleonCms::Admin::PostTagsController
- Defined in:
- app/controllers/camaleon_cms/admin/post_tags_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
render post tag create form.
-
#destroy ⇒ Object
destroy a post tag.
-
#edit ⇒ Object
render post tag edit form.
- #index ⇒ Object
-
#list ⇒ Object
render a json of post tags of a post type.
-
#show ⇒ Object
render post tag view.
-
#update ⇒ Object
save changes of a post tag.
Instance Method Details
#create ⇒ Object
render post tag create form
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 37 def create @post_tag = @post_type..new(params.require(:post_tag).permit!) args = {post_tag: @post_tag, post_type: @post_type}; hooks_run("before_create_post_tag", args) if @post_tag.save @post_tag.(params[:meta]) if params[:meta].present? @post_tag.set_field_values(params[:field_options]) hooks_run("after_create_post_tag", args) flash[:notice] = t('camaleon_cms.admin.post_type.message.created') redirect_to action: :index else render 'edit' end end |
#destroy ⇒ Object
destroy a post tag
52 53 54 55 56 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 52 def destroy args = {post_tag: @post_tag, post_type: @post_type}; hooks_run("before_destroy_post_tag", args) flash[:notice] = t('camaleon_cms.admin.post_type.message.deleted') if @post_tag.destroy redirect_to action: :index end |
#edit ⇒ Object
render post tag edit form
18 19 20 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 18 def edit t("camaleon_cms.admin.button.edit") end |
#index ⇒ Object
6 7 8 9 10 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 6 def index @post_tags = @post_type. args = {post_type: @post_type}; hooks_run("before_list_post_tags", args) @post_tags = @post_tags.paginate(:page => params[:page], :per_page => current_site.admin_per_page) end |
#list ⇒ Object
render a json of post tags of a post type
59 60 61 62 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 59 def list @post_tags = @post_type..pluck("name") render json: @post_tags end |
#show ⇒ Object
render post tag view
13 14 15 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 13 def show args = {post_tag: @post_tag, post_type: @post_type}; hooks_run("before_show_post_tag", args) end |
#update ⇒ Object
save changes of a post tag
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 23 def update args = {post_tag: @post_tag, post_type: @post_type}; hooks_run("before_update_post_tag", args) if @post_tag.update(params.require(:post_tag).permit!) @post_tag.(params[:meta]) if params[:meta].present? @post_tag.set_field_values(params[:field_options]) hooks_run("after_update_post_tag", args) flash[:notice] = t('camaleon_cms.admin.post_type.message.updated') redirect_to action: :index else render edit end end |