Task A: Product Maintenance. #1

Dave says:

I added the following line to the file product.rb in the app/models directory

validates_length_of :title, :minimum => 10

To find the syntax, I looked up the method on http://api.rubyonrails.com You may add an alert message:

validates_length_of :title, :minimum => 10, :message => "at least 10 characters"

Ana says:

You can also use an already implemented error message by using :too_short instead of message. So you can also write:

validates_length_of :title, :minimum => 10, :too_short

Max says:

I'm not sure about the old version of Rails, but you can completely bypass the ":too_short" part, leaving:

validates_length_of :title, :minimum => 10
page_revision: 0, last_edited: 1196811798|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License