Hi, I know this has been mentioned before, but could we do something about validate<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validate>and validates<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates> ? Having two methods with such similar names that do similar things but in a totally different way is extremely confusing. What''s more, if you do use validate instead of validates by mistake, no exceptions are raised and MyModel.valid? will return true. I have trouble remembering which one I should be calling, and I''ve been working with Rails for years now. I can''t imagine how confused a novice programmer would be… Perhaps renaming validate to something like validates_with would be the way to go (with proper deprecation warnings, of course)? Matias -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Matias Korhonen
2013-Dec-13 10:05 UTC
Re: Time to do something about validate & validates?
Whoops, not validates_with since that already exists… Something else (what, I''m not sure). On Friday, 13 December 2013 11:27:00 UTC+2, Matias Korhonen wrote:> > Hi, > > > I know this has been mentioned before, but could we do something about > validate<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validate>and > validates<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates> > ? > > Having two methods with such similar names that do similar things but in a > totally different way is extremely confusing. What''s more, if you do use > validate instead of validates by mistake, no exceptions are raised and > MyModel.valid? will return true. > > I have trouble remembering which one I should be calling, and I''ve been > working with Rails for years now. I can''t imagine how confused a novice > programmer would be… > > Perhaps renaming validate to something like validates_with would be the > way to go (with proper deprecation warnings, of course)? > > > Matias > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Sergio Campamá
2013-Dec-13 11:02 UTC
Re: Re: Time to do something about validate & validates?
what about `validate_with`? On Fri, Dec 13, 2013 at 7:05 AM, Matias Korhonen <korhonen.matt@gmail.com>wrote:> Whoops, not validates_with since that already exists… Something else > (what, I''m not sure). > > > On Friday, 13 December 2013 11:27:00 UTC+2, Matias Korhonen wrote: >> >> Hi, >> >> >> I know this has been mentioned before, but could we do something about >> validate<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validate>and >> validates<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates> >> ? >> >> Having two methods with such similar names that do similar things but in >> a totally different way is extremely confusing. What''s more, if you do use >> validate instead of validates by mistake, no exceptions are raised and >> MyModel.valid? will return true. >> >> I have trouble remembering which one I should be calling, and I''ve been >> working with Rails for years now. I can''t imagine how confused a novice >> programmer would be… >> >> Perhaps renaming validate to something like validates_with would be the >> way to go (with proper deprecation warnings, of course)? >> >> >> Matias >> >> -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Simon Courtois
2013-Dec-13 11:06 UTC
Re: Re: Time to do something about validate & validates?
That wouldn’t really solve the problem since it would change the validate/validates situation to validate_with/validates_with. Simon Courtois On 13 décembre 2013 at 12:03:09, Sergio Campamá (sergio@satelinx.com) wrote: what about `validate_with`? On Fri, Dec 13, 2013 at 7:05 AM, Matias Korhonen <korhonen.matt@gmail.com> wrote: Whoops, not validates_with since that already exists… Something else (what, I''m not sure). On Friday, 13 December 2013 11:27:00 UTC+2, Matias Korhonen wrote: Hi, I know this has been mentioned before, but could we do something about validate and validates? Having two methods with such similar names that do similar things but in a totally different way is extremely confusing. What''s more, if you do use validate instead of validates by mistake, no exceptions are raised and MyModel.valid? will return true. I have trouble remembering which one I should be calling, and I''ve been working with Rails for years now. I can''t imagine how confused a novice programmer would be… Perhaps renaming validate to something like validates_with would be the way to go (with proper deprecation warnings, of course)? Matias -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Sergio Campamá
2013-Dec-13 11:37 UTC
Re: Re: Time to do something about validate & validates?
exactly my point, I think we should add `validates_with` to the `validate` & `validates` issue.... On Fri, Dec 13, 2013 at 8:06 AM, Simon Courtois <happynoff@gmail.com> wrote:> That wouldn’t really solve the problem since it would change the > validate/validates situation to validate_with/validates_with. > > Simon Courtois > > On 13 décembre 2013 at 12:03:09, Sergio Campamá (sergio@satelinx.com<//sergio@satelinx.com>) > wrote: > > what about `validate_with`? > > > On Fri, Dec 13, 2013 at 7:05 AM, Matias Korhonen <korhonen.matt@gmail.com>wrote: > >> Whoops, not validates_with since that already exists… Something else >> (what, I''m not sure). >> >> >> On Friday, 13 December 2013 11:27:00 UTC+2, Matias Korhonen wrote: >>> >>> Hi, >>> >>> >>> I know this has been mentioned before, but could we do something about >>> validate<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validate>and >>> validates<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates> >>> ? >>> >>> Having two methods with such similar names that do similar things but in >>> a totally different way is extremely confusing. What''s more, if you do use >>> validate instead of validates by mistake, no exceptions are raised and >>> MyModel.valid? will return true. >>> >>> I have trouble remembering which one I should be calling, and I''ve been >>> working with Rails for years now. I can''t imagine how confused a novice >>> programmer would be… >>> >>> Perhaps renaming validate to something like validates_with would be the >>> way to go (with proper deprecation warnings, of course)? >>> >>> >>> Matias >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-core+unsubscribe@googlegroups.com. >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Is there are a reason we couldn''t put `options.assert_valid_keys :on, :allow_nil, :allow_blank, :if, :unless` as the second line of the `validate` method? Then if you intend to call `validates` but mistakenly call `validate` you would receive an ArgumentError. If you use them wrong the other way around, it will already give ArgumentError. - Vesa Vänskä On Friday, December 13, 2013 1:37:56 PM UTC+2, Sergio Campamá wrote:> > exactly my point, I think we should add `validates_with` to the `validate` > & `validates` issue.... > > > On Fri, Dec 13, 2013 at 8:06 AM, Simon Courtois <happ...@gmail.com<javascript:> > > wrote: > >> That wouldn’t really solve the problem since it would change the >> validate/validates situation to validate_with/validates_with. >> >> Simon Courtois >> >> On 13 décembre 2013 at 12:03:09, Sergio Campamá (ser...@satelinx.com<javascript:>) >> wrote: >> >> what about `validate_with`? >> >> >> On Fri, Dec 13, 2013 at 7:05 AM, Matias Korhonen <korhon...@gmail.com<javascript:> >> > wrote: >> >>> Whoops, not validates_with since that already exists… Something else >>> (what, I''m not sure). >>> >>> >>> On Friday, 13 December 2013 11:27:00 UTC+2, Matias Korhonen wrote: >>>> >>>> Hi, >>>> >>>> >>>> I know this has been mentioned before, but could we do something about >>>> validate<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validate>and >>>> validates<http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates> >>>> ? >>>> >>>> Having two methods with such similar names that do similar things but >>>> in a totally different way is extremely confusing. What''s more, if you do >>>> use validate instead of validates by mistake, no exceptions are raised >>>> and MyModel.valid? will return true. >>>> >>>> I have trouble remembering which one I should be calling, and I''ve been >>>> working with Rails for years now. I can''t imagine how confused a novice >>>> programmer would be… >>>> >>>> Perhaps renaming validate to something like validates_with would be >>>> the way to go (with proper deprecation warnings, of course)? >>>> >>>> >>>> Matias >>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Core" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to rubyonrails-co...@googlegroups.com <javascript:>. >>> To post to this group, send email to rubyonra...@googlegroups.com<javascript:> >>> . >>> Visit this group at http://groups.google.com/group/rubyonrails-core. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-co...@googlegroups.com <javascript:>. >> To post to this group, send email to rubyonra...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-co...@googlegroups.com <javascript:>. >> To post to this group, send email to rubyonra...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/groups/opt_out. >> > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.