Class: Crowdblog::Admin::PostsController
Instance Method Summary
collapse
#method_missing
Instance Method Details
#create ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 23
def create
@post = Post.new(post_params)
@post.author = current_user
@post.regenerate_permalink
if @post.save
respond_with @post, :location => crowdblog.admin_posts_path
end
end
|
#destroy ⇒ Object
32
33
34
35
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 32
def destroy
@post.destroy
respond_with @post, :location => crowdblog.admin_posts_path
end
|
#edit ⇒ Object
44
45
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 44
def edit
end
|
#index ⇒ Object
16
17
18
19
20
21
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 16
def index
@state = params[:state]
@posts = Post.scoped_for(current_user).for_admin_index
@posts = @posts.with_state(@state) if @state
respond_with @posts
end
|
#new ⇒ Object
8
9
10
11
12
13
14
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 8
def new
@post = Post.new
@post.state = :drafted
@post.author = current_user
@post.save!
redirect_to edit_admin_post_path(@post)
end
|
#show ⇒ Object
37
38
39
40
41
42
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 37
def show
@post = Post.includes(:assets).find(params[:id])
respond_to do |format|
format.json { render json: @post.to_json(include: :assets) }
end
end
|
#update ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 47
def update
@post.update_attributes(post_params)
if @post.allowed_to_update_permalink?
@post.regenerate_permalink
@post.save!
end
respond_with @post do |format|
format.html { redirect_to crowdblog.admin_posts_path }
end
end
|