Forum: Ruby on Rails Problem with error_messages

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9905391b3a73f617a3c0d2e9e32a7273?d=identicon&s=25 zavulon (Guest)
on 2007-04-29 18:02
Hi all,

I have a problem with error_messages displaying correctly. I have a page
to show an item. That page has a comment form (which calls to the
controller 'comment' with action 'create') and below a list of comments
for that item.

The problem is, when I submit a comment that doesn't pass validation,
error messages are not displayed. I think it's because I have the
comments form 'embedded' on the 'show' page. Here is my code, I tried to
trim as much stuff as possible:

Item view: show.rhtml:

  <%= render(:partial => 'item', :locals => { :item => @item }) -%>


  <%= start_form_tag :controller => 'comments', :action => 'create',
:item_id => %>
  <%= render :partial => 'new_comment_form' %>


  <%= error_messages_for 'comment' %>


  <input type="submit" class="button" value="Create">
  <%= end_form_tag %>


  def create
    @comment =[:comment])


      flash[:notice] = 'Thank you! Comment added successfully.'
      redirect_to :controller => 'items', :action => 'show', :id =>
      render :controller => 'items', :action => 'show'
This topic is locked and can not be replied to.