Class: PostCategoriesController
- Inherits:
-
AdminController
- Object
- AdminController
- PostCategoriesController
- Defined in:
- app/controllers/post_categories_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
post /post_categories.
-
#destroy ⇒ Object
delete /post_categories/:id.
-
#edit ⇒ Object
get /post_categories/:id/edit.
-
#new ⇒ Object
get /post_categories/new.
-
#update ⇒ Object
patch /post_categories/:id.
Instance Method Details
#create ⇒ Object
post /post_categories
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/post_categories_controller.rb', line 11 def create @entity = PostCategory.new(creation_parameters) if @entity.save next_page = admin_post_category_path(@entity.id) respond_to do |format| format.html { redirect_to(next_page) } format.json { render json: { links: { self: next_page } } } format.js { render(js: "document.location.href = '#{next_page}'") } end else render :new, status: :bad_request end end |
#destroy ⇒ Object
delete /post_categories/:id
44 45 46 47 48 49 |
# File 'app/controllers/post_categories_controller.rb', line 44 def destroy if @entity.destroy flash[:notice] = t('post_categories.destroy.success') end redirect_to(post_categories_admin_post_type_path(@entity.post_type_id)) end |
#edit ⇒ Object
get /post_categories/:id/edit
26 27 |
# File 'app/controllers/post_categories_controller.rb', line 26 def edit end |
#new ⇒ Object
get /post_categories/new
6 7 8 |
# File 'app/controllers/post_categories_controller.rb', line 6 def new @entity = PostCategory.new end |
#update ⇒ Object
patch /post_categories/:id
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/post_categories_controller.rb', line 30 def update if @entity.update entity_parameters next_page = admin_post_category_path(@entity) respond_to do |format| format.html { redirect_to(next_page, notice: t('post_categories.update.success')) } format.json { render json: { links: { self: next_page } } } format.js { render(js: "document.location.href = '#{next_page}'") } end else render :edit, status: :bad_request end end |