Class: PostCategoriesController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/post_categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

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 = (@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

#destroyObject

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

#editObject

get /post_categories/:id/edit



26
27
# File 'app/controllers/post_categories_controller.rb', line 26

def edit
end

#newObject

get /post_categories/new



6
7
8
# File 'app/controllers/post_categories_controller.rb', line 6

def new
  @entity = PostCategory.new
end

#updateObject

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 = (@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