Re: [Rails] Re: Validates presence

2011-12-13 Thread Javier Quarite
On Tue, Dec 13, 2011 at 8:16 PM, Jim Ruther Nill wrote: > > while this may work in your case, you should remember the following (a > shameless copy > and paste from the api) > > Finally, the options :if, :unless, :on, :allow_blank and :allow_nil can > be given to one specific validator, as a has

Re: [Rails] Re: Validates presence

2011-12-13 Thread Jim Ruther Nill
On Wed, Dec 14, 2011 at 12:41 AM, JavierQQ wrote: > > Well I found the code here: > > > http://stackoverflow.com/questions/1673812/rails-validation-for-users-email-only-want-it-to-validate-when-a-user-signs-up > > validates :score, :presence => true, :if => Proc.new{ (some code > here) } > > wh

[Rails] Re: Validates presence

2011-12-13 Thread JavierQQ
Well I found the code here: http://stackoverflow.com/questions/1673812/rails-validation-for-users-email-only-want-it-to-validate-when-a-user-signs-up validates :score, :presence => true, :if => Proc.new{ (some code here) } -- You received this message because you are subscribed to the Google

[Rails] Re: Validates presence of special conditions not working

2010-01-08 Thread Alpha Blue
Here is the finished validation, corrected: def self.validates_is_exact(*attr_names) options = attr_names.extract_options! validates_each(*(attr_names << options)) do |record, attr_name, value| if record.send( options[:compare_field] ) != value record.errors.add(attr_name, options[:m

[Rails] Re: Validates presence of special conditions not working

2010-01-08 Thread Alpha Blue
I was reading the errors wrong. It's working properly. Thanks Fred for the advice. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegro

[Rails] Re: Validates presence of special conditions not working

2010-01-08 Thread Alpha Blue
Thanks for the explanation Fred. I tried doing this but it's not working properly: def self.validates_is_exact(*attr_names) options = attr_names.extract_options! validates_each(*(attr_names << options)) do |record, attr_name, value| if record.send( options[:compare_field] ) == value

[Rails] Re: Validates presence of special conditions not working

2010-01-08 Thread Frederick Cheung
On Jan 8, 2:59 pm, Alpha Blue wrote: > What I want to do is ensure that if the redirect box is checked for > true, that the name field matches the controller_name field precisely. > > I'm not sure if validates_presence_of will do it.  I may have to create > a custom validation but am unsure how t