Class: Crowdblog::Admin::PostsController
Instance Method Summary
collapse
#method_missing
Instance Method Details
#create ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 22
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
31
32
33
34
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 31
def destroy
@post.destroy
respond_with @post, :location => crowdblog.admin_posts_path
end
|
#edit ⇒ Object
43
44
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 43
def edit
end
|
#index ⇒ Object
15
16
17
18
19
20
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 15
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
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 8
def new
@post = Post.new
@post.author = current_user
@post.save!
redirect_to edit_admin_post_path(@post)
end
|
#show ⇒ Object
36
37
38
39
40
41
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 36
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
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/crowdblog/admin/posts_controller.rb', line 46
def update
@post.update_attributes(post_params, updated_by: current_user)
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
|