Class: Admin::PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::PostsController
show all
- Includes:
- BlogUrlHelpers
- Defined in:
- app/controllers/admin/posts_controller.rb
Instance Method Summary
collapse
#admin_post_comments_path, #admin_post_path, #admin_post_post_comments_path, #admin_posts_path, #edit_admin_post_path, #new_admin_post_path, #post_archive_path, #post_category_archive_path, #post_category_path, #post_path, #posts_path
Instance Method Details
#create ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/admin/posts_controller.rb', line 31
def create
@categories = SpudPostCategory.ordered
@post = SpudPost.new(post_params)
@post.blog_key = params[:blog_key]
if @post.save
flash[:notice] = 'Post was successfully created.'
end
respond_with @post, :location => admin_posts_path
end
|
#destroy ⇒ Object
41
42
43
44
45
46
|
# File 'app/controllers/admin/posts_controller.rb', line 41
def destroy
if @post.destroy
flash[:notice] = 'Post was successfully deleted.'
end
respond_with @post, :location => admin_posts_path
end
|
#edit ⇒ Object
13
14
15
|
# File 'app/controllers/admin/posts_controller.rb', line 13
def edit
respond_with @post
end
|
#index ⇒ Object
8
9
10
11
|
# File 'app/controllers/admin/posts_controller.rb', line 8
def index
@posts = SpudPost.for_blog(params[:blog_key]).ordered.includes(:pending_comments, :author).paginate(:page => params[:page], :per_page => 15)
respond_with @posts
end
|
#new ⇒ Object
25
26
27
28
29
|
# File 'app/controllers/admin/posts_controller.rb', line 25
def new
@categories = SpudPostCategory.ordered
@post = SpudPost.new(:published_at => Time.zone.now, :spud_user_id => current_user.id)
respond_with @post
end
|
#update ⇒ Object
17
18
19
20
21
22
23
|
# File 'app/controllers/admin/posts_controller.rb', line 17
def update
params[:spud_post][:updated_at] = Time.now()
if @post.update_attributes(post_params)
flash[:notice] = 'Post was successfully updated.'
end
respond_with @post, :location => admin_posts_path
end
|