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
|
# File 'app/controllers/admin/post_types_controller.rb', line 15
def create
@post_type = PostType.new(post_type_params)
if @post_type.save
redirect_to admin_post_types_url, notice: "Post type was successfully created."
else
render :index
end
end
|
#destroy ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/admin/post_types_controller.rb', line 33
def destroy
@post_type.transaction do
Article.where("post_type = ?", @post_type.permalink).each do |article|
article.post_type = "read"
article.save
end
@post_type.destroy
end
redirect_to admin_post_types_url, notice: "Post was successfully destroyed."
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
25
26
27
28
29
30
31
|
# File 'app/controllers/admin/post_types_controller.rb', line 25
def update
if @post_type.update(post_type_params)
redirect_to admin_post_types_url, notice: "Post type was successfully updated."
else
render :edit
end
end
|