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
16 17 18 19 20 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 16 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
41 42 43 44 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 41 def destroy @post.destroy render head :ok end |
#edit ⇒ Object
26 27 28 29 30 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 26 def edit if request.xhr? render partial: 'edit', locals: { post: @post } end end |
#edit_slug ⇒ Object
46 47 48 49 50 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 46 def edit_slug if request.xhr? render partial: 'form_slug', locals: { post: @post, version: @version } end end |
#edit_title ⇒ Object
32 33 34 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 32 def edit_title render partial: 'form', locals: { post: @post } end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 6 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
11 12 13 14 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 11 def new @post = Pulitzer::Post.new(post_type_id: params[:post_type_id]) render partial: 'new', locals: { post: @post } end |
#show ⇒ Object
22 23 24 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 22 def show render partial: 'show', locals: { post: @post } end |
#show_slug ⇒ Object
52 53 54 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 52 def show_slug render partial: 'show_slug', locals: { post: @post, version: @version } end |
#update ⇒ Object
36 37 38 39 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 36 def update @post.update_attributes(post_params) render partial: 'show', locals: { post: @post } end |
#update_slug ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/controllers/pulitzer/posts_controller.rb', line 56 def update_slug @post.update_attributes(post_params) if @version.preview? route = "#{Pulitzer.preview_namespace}_#{@post.post_type.name.parameterize('_')}_path" @preview_path = main_app.public_send(route, @post.slug) if main_app.respond_to?(route) end render partial: 'pulitzer/posts/edit', locals: { version: @version, post: @post } end |