This project is archived and is in readonly mode.

#3246 ✓resolved
Lachlan Sylvester

[PATCH] error_message_on does not display error message when form builder is not passed object

Reported by Lachlan Sylvester | September 22nd, 2009 @ 10:46 AM

When form_for is invoked using a name and not an object, error_message_on returns an empty string instead of an error message.

    
form_for(:post) do |f|
   concat f.error_message_on('author_name')
   concat f.error_messages
end

Results in:


<form action='http://www.example.com' method='post'>
  <div class="errorExplanation" id="errorExplanation">
    <h2>1 error prohibited this post from being saved</h2>
    <p>There were problems with the following fields:</p>
    <ul><li>Author name can't be empty</li></ul>
  </div>
</form>

This patch will pass in the @object_name if there is no @object.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages