hirolibe / insta-app-hiro

0 stars 0 forks source link

気づき(記事へのコメント) #11

Open hirolibe opened 3 weeks ago

hirolibe commented 3 weeks ago

特定の記事にコメントしたユーザー情報の付与 @comment.user = current_user

def create
  album = Album.find(params[:album_id])
  @comment = album.comments.build(comment_params)
  @comment.user = current_user
  if @comment.save
    redirect_to album_comments_path(album_id: album.id)
  else
    flash.now[:error] = 'コメントできませんでした'
    render :new
  end
end