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
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 14 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
35 36 37 38 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 35 def destroy @post.destroy render head :ok end |
#edit ⇒ Object
24 25 26 27 28 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 24 def edit if request.xhr? render partial: 'form', locals: { post: @post } end end |
#index ⇒ Object
4 5 6 7 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 4 def index @post_type = Pulitzer::PostType.find params[:post_type_id] @posts = Pulitzer::Post.where post_type: @post_type end |
#new ⇒ Object
9 10 11 12 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 9 def new @post = Pulitzer::Post.new(post_type_id: params[:post_type_id]) render partial: 'new', locals: { post: @post } end |
#show ⇒ Object
20 21 22 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 20 def show render partial: 'show', locals: { post: @post } end |
#update ⇒ Object
30 31 32 33 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 30 def update @post.update_attributes(post_params) render partial: 'show', locals: { post: @post } end |