Class: PostGroupsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/post_groups_controller.rb

Overview

Handling post groups

Instance Method Summary collapse

Instance Method Details

#checkObject

post /post_groups/check



11
12
13
14
15
# File 'app/controllers/post_groups_controller.rb', line 11

def check
  @entity = PostGroup.instance_for_check(params[:entity_id], entity_parameters)

  render 'shared/forms/check'
end

#createObject

post /post_groups



23
24
25
26
27
28
29
30
# File 'app/controllers/post_groups_controller.rb', line 23

def create
  @entity = PostGroup.new(entity_parameters)
  if @entity.save
    form_processed_ok(admin_post_group_path(id: @entity.id))
  else
    form_processed_with_error(:new)
  end
end

#destroyObject

delete /post_groups/:id



46
47
48
49
50
# File 'app/controllers/post_groups_controller.rb', line 46

def destroy
  flash[:notice] = t('post_groups.destroy.success') if @entity.destroy

  redirect_to post_groups_admin_post_type_path(id: @entity.post_type_id)
end

#editObject

get /post_groups/:id/edit



33
34
# File 'app/controllers/post_groups_controller.rb', line 33

def edit
end

#newObject

get /post_groups/new



18
19
20
# File 'app/controllers/post_groups_controller.rb', line 18

def new
  @entity = PostGroup.new
end

#showObject

get /post_groups/:id



53
54
55
56
57
58
59
60
# File 'app/controllers/post_groups_controller.rb', line 53

def show
  @entity = PostGroup.visible.find_by(slug: params[:id])
  if @entity.nil?
    handle_http_404('Cannot find post_group')
  else
    @collection = @entity.posts_page(current_page)
  end
end

#updateObject

patch /post_groups/:id



37
38
39
40
41
42
43
# File 'app/controllers/post_groups_controller.rb', line 37

def update
  if @entity.update(entity_parameters)
    form_processed_ok(admin_post_group_path(id: @entity.id))
  else
    form_processed_with_error(:edit)
  end
end