Class: Pulitzer::PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Pulitzer::PostsController
- Defined in:
- app/controllers/pulitzer/posts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #edit_slug ⇒ Object
- #edit_title ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #show_slug ⇒ Object
- #update ⇒ Object
- #update_slug ⇒ Object
Instance Method Details
#create ⇒ Object
15 16 17 18 19 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 15 def create @post = Pulitzer::Post.create(post_params) Pulitzer::CreatePostContentElements.new(@post).call if @post render partial: 'show_wrapper', locals: { post: @post } end |
#destroy ⇒ Object
40 41 42 43 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 40 def destroy @post.destroy render head :ok end |
#edit ⇒ Object
25 26 27 28 29 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 25 def edit if request.xhr? render partial: 'edit', locals: { post: @post } end end |
#edit_slug ⇒ Object
45 46 47 48 49 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 45 def edit_slug if request.xhr? render partial: 'form_slug', locals: { post: @post } end end |
#edit_title ⇒ Object
31 32 33 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 31 def edit_title render partial: 'form', locals: { post: @post } end |
#index ⇒ Object
5 6 7 8 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 5 def index @post_type = Pulitzer::PostType.find params[:post_type_id] @posts = Pulitzer::Post.where(post_type: @post_type).order(id: :desc) end |
#new ⇒ Object
10 11 12 13 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 10 def new @post = Pulitzer::Post.new(post_type_id: params[:post_type_id]) render partial: 'new', locals: { post: @post } end |
#show ⇒ Object
21 22 23 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 21 def show render partial: 'show', locals: { post: @post } end |
#show_slug ⇒ Object
51 52 53 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 51 def show_slug render partial: 'show_slug', locals: { post: @post } end |
#update ⇒ Object
35 36 37 38 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 35 def update @post.update_attributes(post_params) render partial: 'show', locals: { post: @post } end |
#update_slug ⇒ Object
55 56 57 58 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 55 def update_slug @post.update_attributes(post_params) render partial: 'show_slug', locals: { post: @post } end |