Hi Avishai, i just tried this:
irb(main):001:0> "G@I$G@GR#&GUGshkj4h53$$$*@^".to_i => 0 As I don't know how the conversion would work, but if it works like that it will return 0. But it still should not be valid.Hmmm. Bernd 2011/7/13 Avishai Weiss <[email protected]> > Yes, the price is random junk that's clearly supposed to fail validation, > but it passes with no errors. > > I just tried it with the validations after the field definitions; still the > same problem. > > Cheers, > > Avishai > > On Wed, Jul 13, 2011 at 12:42 PM, Bernd Ritter <[email protected]> wrote: > >> Hi, >> >> that price looks like random stuff. Is it relevant that you call the >> validator before the field-definition? >> >> Greetings, >> Bernd >> >> >> 2011/7/13 Avishai <[email protected]> >> >>> Hi, >>> >>> I'm having some serious problems with my validations. I have a mongoid >>> model set up with validations, which looks like this: >>> >>> class Apartment >>> include Mongoid::Document >>> include Mongoid::Timestamps >>> validates :price, :numericality => { :greater_than => 0, :allow_blank >>> => false } >>> field :price, :type => Integer >>> end >>> >>> But then when I actually try to run the validations, they pass and claim >>> the object is valid, even if I pass complete garbage. Here's the output: >>> >>> ruby-1.9.2-p180 :006 > Apartment.validators_on(:price) >>> => [#<ActiveModel::Validations::NumericalityValidator:0x00000102924cc8 >>> @attributes=[:price], @options={:only_integer=>false, :allow_nil=>false, >>> :greater_than=>0, :allow_blank=>false}>] >>> ruby-1.9.2-p180 :007 > a = Apartment.new(:price => "G@I$G@GR >>> #&GUGshkj4h53$$$*@^") >>> => #<Apartment _id: 4e1d66f835be35fddb000002, _type: nil, created_at: >>> nil, updated_at: nil, address: nil, price: "G@I$G@GR >>> #&GUGshkj4h53$$$*@^"> >>> ruby-1.9.2-p180 :008 > a.valid? >>> => true >>> >>> I've tried disabling gems, commenting out and then re-adding validations >>> one by one, but nothing seems to work. If you have any fresh direction on >>> how to track this down, I'd really appreciate it. Thanks! >>> >>> -Avishai >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Ruby on Rails: Talk" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/rubyonrails-talk/-/u8C4AV2SfNQJ. >>> 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-talk?hl=en. >>> >> >> -- >> 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 [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-talk?hl=en. >> > > -- > 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 [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-talk?hl=en. > -- 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 [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-talk?hl=en.

