I am trying to create blogging software using Ruby on Rails. I have a CommentsController class and an EntriesController class. The file app/views/entries/show.html.erb contains the code "<%= render 'comments/form' %>", which displays a form on the page for an individual entry to add a comment on that entry. When a user submits a comment but does something invalid like submit a blank comment or a blank name I want the user to be redirected back to the entry's page with the comment filled out with whatever data was filled in. I tried the following code inside my "create" function in the comments_controller.rb file: respond_to do |format| if !(@comment.user_id.blank? && (@comment.guest_name.blank? || @comment.guest_email.blank?)) && @comment.save format.html { redirect_to Entry.find(@comment.entry_id), notice: 'Comment was successfully created.' } format.json { render json: @comment, status: :created, location: @comment } else if @comment.nil? format.html { redirect_to "/entries" } else format.html { render :template => "/entries/show.html" } end format.json { render json: @comment.errors, status: :unprocessable_entity } end end I realize that the line 'format.html { render :template => "/entries/show.html" }' is incorrect. One problem is that the URL does not contain the entry's ID, but when I replaced "entries.show.html" with '"/entries/"+@comment.entry_id.to_s' it says "Missing template entries/1 with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}." When I replace the "render :template => " with "redirect_to", I get redirected back to the page that I want to but the form data is not filled out with whatever the user filled in. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/aab93a4cf83a40af630f69fbddd62aeb%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.