This project is archived and is in readonly mode.
validates_numericality_of does not work with negative values
Reported by Nico Schottelius | July 5th, 2010 @ 05:17 PM
validates_numericality_of :count, :greater_than_or_equal_to => 0, :only_integer => true
Allows me to specifiy -1 or -10
[17:01] kr:rdb% rails --version
Rails 3.0.0.beta3
[18:16] kr:rdb% ruby --version ruby 1.9.2dev (2010-06-12 revision
28290) [x86_64-linux]
Comments and changes to this ticket
-
Rohit Arondekar July 6th, 2010 @ 10:36 AM
- State changed from new to invalid
- Importance changed from to Low
Can you please upgrade to Rails 3 Beta 4? I cannot reproduce this in Rails Master on 1.9.2.
I've closed this ticket, but if it's still an issue after upgrading then just leave a comment and I'll reopen it. :)
-
Nico Schottelius July 6th, 2010 @ 01:47 PM
Also fails for beta4:
Entering -34 and it validation "works".
-
Nico Schottelius July 6th, 2010 @ 01:57 PM
And here's the full version blob:
[14:47] kr:rdb% rails --version Rails 3.0.0.beta4 [14:57] kr:rdb% bundle show Gems included by the bundle: * abstract (1.0.0) * actionmailer (3.0.0.beta4) * actionpack (3.0.0.beta4) * activemodel (3.0.0.beta4) * activerecord (3.0.0.beta4) * activeresource (3.0.0.beta4) * activesupport (3.0.0.beta4) * arel (0.4.0) * builder (2.1.2) * bundler (0.9.26) * erubis (2.6.6) * i18n (0.4.1) * mail (2.2.5) * mime-types (1.16) * polyglot (0.3.1) * rack (1.1.0) * rack-mount (0.6.6) * rack-test (0.5.4) * rails (3.0.0.beta4) * railties (3.0.0.beta4) * rake (0.8.7) * sqlite3-ruby (1.3.0) * thor (0.13.7) * treetop (1.4.8) * tzinfo (0.3.22) [14:57] kr:rdb%
Edited by Rohit Arondekar for formating.
-
Rohit Arondekar July 6th, 2010 @ 04:58 PM
- State changed from invalid to open
I'm pretty sure this is fixed in Rails master. But still opening ticket.
Can somebody please try and reproduce this?
-
Subba July 16th, 2010 @ 09:33 PM
- Assigned user set to Rohit Arondekar
i am unble to reproduce this in beta4.
can we resolve this ticket.class Newspaper < ActiveRecord::Base set_table_name :papers set_primary_key :paper_id validates_numericality_of :paper_size, :greater_than_or_equal_to => 0, :only_integer => true def self.lab Newspaper.create!(:paper_size => -2) end end
-
Rohit Arondekar July 17th, 2010 @ 05:34 AM
Nico, is there anything else that needs to be done to reproduce this issue?
-
Nico Schottelius July 17th, 2010 @ 02:19 PM
As lighthouse does not accept my mail reply, here's a 1:1 copy:
Subba updated this ticket at July 16th, 2010 @ 09:33 PM
i am unble to reproduce this in beta4. can we resolve this ticket.
Strange, it works fine in a brand new application with beta4.
Will have to debug what's wrong in the existing application.
Just close the ticket.
Edited by Rohit Arondekar for formating.
-
Rohit Arondekar July 18th, 2010 @ 03:29 AM
- State changed from open to invalid
Nico, no problem. Please do update the ticket if it turns out to be a rails issue and I'll reopen the ticket.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>