Ops, it's a to_a

class Table
 validates_inclusion_of :value, :in =>  (1..7).to_a
end


-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)



On Wed, Feb 25, 2009 at 3:54 PM, Maurício Linhares
<[email protected]> wrote:
> This isn't someithing to be done inside a migration, but at your model
> as a validation:
>
> class Table
>  validates_inclusion_of :value, :in =>  (1..7).to_i
> end
>
>
> -
> Maurício Linhares
> http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)
>
>
>
> On Wed, Feb 25, 2009 at 3:49 PM, Guillaume Loader
> <[email protected]> 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 via http://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