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 => @item.id %>
  <%= render :partial => ''new_comment_form'' %>
_new_comment_form.rhtml:
  ...
  <%= error_messages_for ''comment'' %>
  ...
  <input type="submit" class="button"
value="Create">
  <%= end_form_tag %>
comments_controller.rb:
  def create
    @comment = Comment.new(params[:comment])
    ...
    if @comment.save
      flash[:notice] = ''Thank you! Comment added
successfully.''
      redirect_to :controller => ''items'', :action =>
''show'', :id =>
@comment.item_id
    else
      render :controller => ''items'', :action =>
''show''
    end
  end
-- 
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---