Class: Pulitzer::PostsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pulitzer/posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



35
36
37
38
# File 'app/controllers/pulitzer/posts_controller.rb', line 35

def destroy
  @post.destroy
  render head :ok
end

#editObject



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

#indexObject



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

#newObject



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

#showObject



20
21
22
# File 'app/controllers/pulitzer/posts_controller.rb', line 20

def show
  render partial: 'show', locals: { post: @post }
end

#updateObject



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