Problem with error_messages

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’ %>

<%= 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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs