Add to model

validates_numericality_of :value,
  :only_integer => true,
  :less_than_or_equal_to => 7,
  :greater_than_or_equal_to => 1

to get the inclusive [1-7] int only

On Feb 25, 8:49 am, Guillaume Loader <rails-mailing-l...@andreas-
s.net> wrote:
> Hello everyone!
>
> I want to add a column to a table. So here is my migration. My question
> is : Is it possible to say that this value must be between 1 and 7 and
> must no be a float (1.4 shouldn't be possible) ?
>
> class AddValueToTable < ActiveRecord::Migration
>   def self.up
>     add_column :table, :value, :int
>   end
>
>   def self.down
>     remove_column :table, :value
>   end
> end
>
> Thank you for your help!
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to