app/controllers/posts_controller.rb
#associates current user with new post. also finds or creates an artist for the new post
#if the post saves (validation) then it shows the newly created post. if not, an alert is flashed and user is redirected to the new post page (again)

associates current user with new post. also finds or creates an artist for the new post
if the post saves (validation) then it shows the newly created post. if not, an alert is flashed and user is redirected to the new post page (again)
associates current user with new post . also finds or creates an artist for the new post if the post saves ( validation ) then it shows the newly created post . if not an alert is flashed and user is redirected to the new post page ( again )
def create 
        @post = Post.new(post_params)
        @post.user = User.find(current_user.id)
        @post.artist = Artist.find_or_create_by(post_params[:artist_attributes])
        if @post.save
           render :show
        else
                flash[:alert] = 'Fill in all boxes!'
            redirect_to '/posts/new'
        end  
    end
def create @post = Post . new ( post_params ) @post . user = User . find ( current_user . id ) @post . artist = Artist . find_or_create_by ( post_params [ :artist_attributes ] ) if @post . save render :show else flash [ :alert ] = 'Fill in all boxes!' redirect_to '/posts/new' end end
associates current user with new post.
associates current user with new post .