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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -