[openstreetmap/openstreetmap-website] Numericality validation typo - should be `only_integer` instead of `integer_only` (#2355)

whoisutsav notifications at github.com
Thu Aug 22 02:00:00 UTC 2019


Hi,

There are a number of fields in the models which are validated for numericality, using the flag `integer_only`:
```
[openstreetmap-website] $ grep -rin "integer_only" .
./app/models/old_node.rb:41:                       :numericality => { :integer_only => true }
./app/models/old_node.rb:43:                        :numericality => { :integer_only => true }
./app/models/note.rb:27:                 :numericality => { :on => :update, :integer_only => true }
./app/models/changeset_comment.rb:27:                 :numericality => { :on => :update, :integer_only => true }
./app/models/node.rb:50:                 :numericality => { :on => :update, :integer_only => true }
./app/models/node.rb:52:                      :numericality => { :integer_only => true }
./app/models/node.rb:54:                           :numericality => { :integer_only => true }
./app/models/node.rb:56:                       :numericality => { :integer_only => true }
./app/models/node.rb:58:                        :numericality => { :integer_only => true }
./app/models/way.rb:42:                 :numericality => { :on => :update, :integer_only => true }
./app/models/way.rb:44:                      :numericality => { :integer_only => true }
./app/models/way.rb:46:                           :numericality => { :integer_only => true }
./app/models/changeset.rb:46:                 :numericality => { :on => :update, :integer_only => true }
./app/models/changeset.rb:48:                      :numericality => { :integer_only => true }
./app/models/changeset.rb:50:                          :numericality => { :integer_only => true,
./app/models/changeset.rb:54:                                                    :numericality => { :integer_only => true }
./app/models/note_comment.rb:31:                 :numericality => { :on => :update, :integer_only => true }
./app/models/relation.rb:40:                 :numericality => { :on => :update, :integer_only => true }
./app/models/relation.rb:42:                      :numericality => { :integer_only => true }
./app/models/relation.rb:44:                           :numericality => { :integer_only => true }
```

However I believe the flag accepted by the Rails numericality API is `only_integer`, _not_ `integer_only`. See [here](https://github.com/rails/rails/blob/b9ca94caea2ca6a6cc09abaffaad67b447134079/activemodel/lib/active_model/validations/numericality.rb#L12).

Perhaps the flag has changed since previous Rails versions? Nevertheless, the code linked above is from the app version of Rails (5.2.3), so it seems these numericality validations may now be silently ignored. Found this while analyzing the app as part of a research project. Happy to create a pull request if that's helpful (and others agree this is an issue). Thanks.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/2355
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20190821/cd722481/attachment.html>


More information about the rails-dev mailing list