The intro to this topic: https://github.com/kaize/valle. This problem is 
not new. There are some similar gems, e.g. 
http://github.com/rubiety/validates_lengths_from_database. All, in general, 
do the same thing - get information about the limitations (length or 
maximum/minimum value) and apply them to the model.

At this moment, limit is only used for mapping between ActiveRecord and 
database. For example (suppose we have PostgreSQL DB):

migration with
    t.integer :age, limit: 2
transforms into `age smallint` in PostgreSQL.


But, default integer field do not have limit:

migration with
    t.integer :age
transforms into `age integer` in PostgreSQL. 


PostgreSQL actually can store only 4 bytes.

This means: "*limit inside AbstractAdapter::Column does not mean the actual 
limit in the database for that type*"

I would like to ask does it make sense (to Rails):
1) to field to store actual limit for that type?
2) to implement an automatic check if value is out of acceptable range?

Regards,
Anton

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/qxaWMMTLxmsJ.
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-core?hl=en.

Reply via email to