Class: CamaleonCms::Admin::PostTagsController
- Inherits:
-
CamaleonCms::AdminController
- Object
- CamaleonController
- CamaleonCms::AdminController
- CamaleonCms::Admin::PostTagsController
- Includes:
- CustomFieldsConcern
- 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.
Methods inherited from CamaleonCms::AdminController
#ajax, #cama_get_i18n_frontend, #dashboard, #search
Instance Method Details
#create ⇒ Object
render post tag create form
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 45 def create @post_tag = @post_type..new(post_tag_params) 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(('PostType_PostTag')) 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
61 62 63 64 65 66 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 61 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
25 26 27 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 25 def edit t('camaleon_cms.admin.button.edit') end |
#index ⇒ Object
11 12 13 14 15 16 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 11 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
69 70 71 72 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 69 def list @post_tags = @post_type..pluck('name') render json: @post_tags end |
#show ⇒ Object
render post tag view
19 20 21 22 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 19 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
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 30 def update args = { post_tag: @post_tag, post_type: @post_type } hooks_run('before_update_post_tag', args) if @post_tag.update(post_tag_params) @post_tag.(params[:meta]) if params[:meta].present? @post_tag.set_field_values(('PostType_PostTag')) 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 |