ruby on rails - Redirect works but render fails on the same path for my comment system -
hello guys~ i'm kind of new rails here. , have controler in create action, failed creation comment direct "template missing". wonder how solve since success working alright same path ... thank much~
def create @book = book.find(params[:book_id]) @comment = @book.comments.build(params[:comment]) if signed_in? @comment.user = current_user if @comment.save flash[:success] = "comment posted" redirect_to book_path(@book) else render book_path(@book) end end
routes
resources :books resources :comments, only: [:create, :destroy] end
use render :show
.
render
not accept url this. accepts name of template rendering, among other things. check out documentation more examples of can pass render
.
Comments
Post a Comment