I've just implemented friendly_id for my post urls but creating comments error with "No route matches {:action=>"show", :controller=>"posts", :id=>nil} missing required keys: [:id]"
comments controller
before_filter :authenticate_user!
def create
@comment = Comment.new(comment_params)
@comment.post_id = params[:post_id]
@comment.user_id = current_user.id
@comment.save
redirect_to post_path(@comment.post)
end
def comment_params
params.require(:comment).permit(:user_id, :body)
end
I've tested removing friendly_id and it's definately this messing with it. I assume it's because creating a comment directs to url/posts/post-name/comments (friendly_id) when it's looking for url/posts/post-id/comments.
Any ideas?