I always do that too :( On Sunday, November 4, 2012 11:31:01 AM UTC-2, Matt Huggins wrote: > > My main issue with "validates" is that it's easy to mix up with "validate" >> ( >> http://apidock.com/rails/v3.2.8/ActiveModel/Validations/ClassMethods/validate >> ). > > > This is my biggest issue as well. Every time I start writing validations, > I have to refer to old code to see which method is correct. > > > On Saturday, November 3, 2012 12:57:26 PM UTC-4, Henrik N wrote: >> >> >> On Friday, November 2, 2012 4:22:38 PM UTC+1, Jeff Cohen wrote: >>> >>> Rails 3 brought a slow death to another area of wonderful DSL-ness: >>> validations. Instead of this: >>> >>> validates_presence_of :title >>> >>> we're now supposed to use the generic form: >>> >>> validates :title, :presence => true >>> >> >> My main issue with "validates" is that it's easy to mix up with >> "validate" ( >> http://apidock.com/rails/v3.2.8/ActiveModel/Validations/ClassMethods/validate >> ). >> >> If you accidentally do "validate :title, presence: true", it will >> effectively do nothing, and won't explode - it will call the "title" method >> and expect that method to add validation errors, and "presence: true" just >> becomes an ignored option. >> >> Tests will catch this, of course, but it's still an easy mistake to make. >> >> I'm not sure what would be a good solution, though. Maybe complaining >> about unknown options? >> >
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/UmTpdWGuw9gJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
