Class: Miniblog::Admin::PostsController
Instance Method Summary
collapse
#after_post_is_saved
#method_missing
Instance Method Details
#create ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/miniblog/admin/posts_controller.rb', line 18
def create
@post = Post.new(post_params)
@post.state = :drafted
@post.author = current_user
@post.regenerate_permalink
if @post.save
after_post_is_saved
redirect_to miniblog.edit_admin_post_path(@post), notice: "Post created succesfully"
else
render action: :new
end
end
|
#destroy ⇒ Object
31
32
33
34
|
# File 'app/controllers/miniblog/admin/posts_controller.rb', line 31
def destroy
@post.destroy
redirect_to miniblog.admin_posts_path
end
|
#edit ⇒ Object
40
41
|
# File 'app/controllers/miniblog/admin/posts_controller.rb', line 40
def edit
end
|
#index ⇒ Object
12
13
14
15
16
|
# File 'app/controllers/miniblog/admin/posts_controller.rb', line 12
def index
@state = params[:state]
@posts = Post.for_admin_index
@posts = @posts.with_state(@state) if @state
end
|
#new ⇒ Object
6
7
8
9
10
|
# File 'app/controllers/miniblog/admin/posts_controller.rb', line 6
def new
@post = Post.new
@post.state = :drafted
@post.author = current_user
end
|
#show ⇒ Object
36
37
38
|
# File 'app/controllers/miniblog/admin/posts_controller.rb', line 36
def show
@post = Post.includes(:assets).find(params[:id])
end
|
#update ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/controllers/miniblog/admin/posts_controller.rb', line 43
def update
handle_asset
if @post.update_attributes(post_params)
if @post.allowed_to_update_permalink?
@post.regenerate_permalink
@post.save!
end
after_post_is_saved
flash[:notice] = "Post updated succesfully"
end
render action: :edit
end
|