Class: Admin::PostsController
Instance Method Summary
collapse
#render_post_action
#admin_post_path, #admin_post_preview_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
33
34
35
36
37
38
|
# File 'app/controllers/admin/posts_controller.rb', line 33
def create
@post = SpudPost.new(post_params)
@post.blog_key = params[:blog_key]
flash[:notice] = 'Post was successfully created.' if @post.save
respond_with @post, location: admin_posts_path
end
|
#destroy ⇒ Object
40
41
42
43
|
# File 'app/controllers/admin/posts_controller.rb', line 40
def destroy
flash[:notice] = 'Post was successfully deleted.' if @post.destroy
respond_with @post, location: admin_posts_path
end
|
#edit ⇒ Object
16
17
18
|
# File 'app/controllers/admin/posts_controller.rb', line 16
def edit
respond_with @post
end
|
#index ⇒ Object
10
11
12
13
14
|
# File 'app/controllers/admin/posts_controller.rb', line 10
def index
@posts = SpudPost.for_blog(params[:blog_key]).ordered.paginate(page: params[:page], per_page: 15)
@posts = @posts.search(params[:search]) if params[:search]
respond_with @posts
end
|
#new ⇒ Object
28
29
30
31
|
# File 'app/controllers/admin/posts_controller.rb', line 28
def new
@post = SpudPost.new(published_at: Time.zone.now, spud_user_id: current_user.id)
respond_with @post
end
|
#preview ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/admin/posts_controller.rb', line 45
def preview
@post = if params[:post_id]
SpudPost.find_by!(id: params[:post_id])
else
SpudPost.new
end
@post.assign_attributes(post_params)
render_post_action :show, controller: :posts, layout: @config.layout
end
|
#show ⇒ Object
20
21
|
# File 'app/controllers/admin/posts_controller.rb', line 20
def show
end
|
#update ⇒ Object
23
24
25
26
|
# File 'app/controllers/admin/posts_controller.rb', line 23
def update
flash[:notice] = 'Post was successfully updated.' if @post.update(post_params)
respond_with @post, location: admin_posts_path
end
|