Colin Law wrote in post #993612: > On 18 April 2011 18:22, Tony Tony <li...@ruby-forum.com> wrote: >> >> The show view form for the comment is the following: >> However I am getting the following error only when validation fails (if >> a normal length comment is created the site works): >> >> [code] >> Template is missing >> >> Missing template comments/create with {:handlers=>[:erb, :rjs, :builder, >> :rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]} in view paths >> "/...", "/.../.rvm/gems/ruby-1.9.2-head/gems/devise-1.2.1/app/views" >> [/code] > > What does the code for action create in the controller look like? > What happens in there if the validation fails (ie save will return > zero). What view does it attempt to show in that case? > > Colin
Hi Colin, Ok so I just figured out the main problem was with the create action in CommentsController. I had: def create @post = Post.find(params[:post_id]) @comment = @post.comments.new(params[:comment]) @comment.user_id = current_user.id if @comment.save redirect_to @post end end What I needed was to add an else statement to @comment.save like so: def create @post = Post.find(params[:post_id]) @comment = @post.comments.new(params[:comment]) @comment.user_id = current_user.id if @comment.save redirect_to @post else redirect_to @post end end Now the problem I'm having showing the validation errors on my post show form (code in my original message). Any tips on displaying that? Thanks! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.