Class: Admin::PostTypesController
Instance Method Summary
collapse
Methods included from BlogHelper
#blog_base_url, #this_blog
Instance Method Details
#create ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/admin/post_types_controller.rb', line 15
def create
@post_type = PostType.new(post_type_params)
if @post_type.save
flash[:notice] = I18n.t("admin.base.successfully_created",
name: PostType.model_name.human)
redirect_to admin_post_types_url
else
render :index
end
end
|
#destroy ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/admin/post_types_controller.rb', line 37
def destroy
@post_type.transaction do
Article.where(post_type: @post_type.permalink).find_each do |article|
article.post_type = "read"
article.save
end
@post_type.destroy
end
flash[:notice] = I18n.t("admin.base.successfully_deleted",
name: PostType.model_name.human)
redirect_to admin_post_types_url
end
|
#edit ⇒ Object
11
12
13
|
# File 'app/controllers/admin/post_types_controller.rb', line 11
def edit
@post_types = PostType.all
end
|
#index ⇒ Object
6
7
8
9
|
# File 'app/controllers/admin/post_types_controller.rb', line 6
def index
@post_types = PostType.all
@post_type = PostType.new
end
|
#update ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/admin/post_types_controller.rb', line 27
def update
if @post_type.update(post_type_params)
flash[:notice] = I18n.t("admin.base.successfully_updated",
name: PostType.model_name.human)
redirect_to admin_post_types_url
else
render :edit
end
end
|