Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

validates_numericality_of does not work with negative values

#5049

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]

Reported by Nico Schottelius · July 5th, 2010 @ 05:17 PM

State: invalid
Milestone: none
Assigned to: Rohit Arondekar Rohit Arondekar
Importance: Low

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • 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. :)

    July 6th, 2010 @ 10:36 AM

  2. Nico Schottelius
    Nico Schottelius

    Also fails for beta4:

    Entering -34 and it validation "works".

    July 6th, 2010 @ 01:47 PM

  3. Nico Schottelius
    Nico Schottelius

    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.

    July 6th, 2010 @ 01:57 PM

  4. Rohit Arondekar
    Rohit Arondekar
    • 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?

    July 6th, 2010 @ 04:58 PM

  5. Miles Egan
    Miles Egan

    I haven't been able to reproduce this in beta4 or master.

    July 10th, 2010 @ 04:44 PM

  6. Subba
    Subba
    • 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
    

    July 16th, 2010 @ 09:33 PM

  7. Rohit Arondekar
    Rohit Arondekar

    Nico, is there anything else that needs to be done to reproduce this issue?

    July 17th, 2010 @ 05:34 AM

  8. Nico Schottelius
    Nico Schottelius

    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.

    July 17th, 2010 @ 02:19 PM

  9. Rohit Arondekar
    Rohit Arondekar
    • 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.

    July 18th, 2010 @ 03:29 AM

  10. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:52 PM

  11. Jeff Kreeftmeijer
  12. bingbing