Sha256: 8816c891c79b1624eb27489f28e11a38842e1195a98e2cfda85e9f89ee78f639
Contents?: true
Size: 1 KB
Versions: 6
Compression:
Stored size: 1 KB
Contents
class Pulitzer::PostsController < Pulitzer::ApplicationController before_filter :get_post, only: [:show, :edit, :update] def index @post_type = Pulitzer::PostType.find params[:post_type_id] @posts = Pulitzer::Post.where post_type: @post_type end def new @post = Pulitzer::Post.new(post_type_id: params[:post_type_id]) render partial: 'new', locals: { post: @post } end def create @post = Pulitzer::Post.create(post_params) Pulitzer::SetupPostElements.new(@post).call if @post render partial: 'show_wrapper', locals: { post: @post } end def show render partial: 'show', locals: { post: @post } end def edit render partial: 'form', locals: { post: @post } end def update @post.update_attributes(post_params) render partial: 'show', locals: { post: @post } end def destroy @post.destroy render head :ok end protected def post_params params[:post].permit! end def get_post @post = Pulitzer::Post.find(params[:id]) end end
Version data entries
6 entries across 6 versions & 1 rubygems