Forum: Ruby on Rails validation question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel S. (Guest)
on 2007-01-24 03:28
This one I cant seem to wrap my head around...

I have a form that I would like to bring up a :confirm => "are you sure
you want to change your username, doing so may make you foo up."
but only if a user changes that particular field.

So basically I have:
          <tr>
            <th><label for="user_name">User name</label></th>
            <td><%= f.text_field 'name' %></td>
          </tr>
          <tr>
            <th><label for="user_email">Email</label></th>
            <td><%= f.text_field 'email' %></td>
          </tr>
          <tr><%= submit_tag("Save changes") %></tr>

is there something as easy as
validates_change_of :user_name


and if not, what would be a good suggestion an approaching this.


(that would be a nice validates addition if it doesnt exist!)

-daniel
This topic is locked and can not be replied to.