try looking 
Here<http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001401>
.
Sempre Alerta Para Servir,

Lucas Franceschi
Equipe de Programação (Automação)
SGI Sistemas
(049) 9922-3360


On Thu, Jun 17, 2010 at 12:14 PM, lucas franceschi <[email protected]>wrote:

> well... in fact... you did defined it as an "integer" so, dont expect to
> get any other class thats not Fixnum or Bignum...
>
> but, you can also use some model validations to be sure that the user
> entered an integer...
>
> try validates_numericality_of :cost
> it will stop your user from entering strings....
>
> i`m not sure how to stop it from entering floats like "10.6", but i`m sure
> there's a simple way of doing it...
>
> you know, you're programming in ruby on rails, it IS simple.
> Sempre Alerta Para Servir,
>
> Lucas Franceschi
> Equipe de Programação (Automação)
> SGI Sistemas
> (049) 9922-3360
>
>
>
> On Thu, Jun 17, 2010 at 11:35 AM, Stanislav Orlenko 
> <[email protected]>wrote:
>
>> Colin Law wrote:
>> > On 16 June 2010 11:34, Stanislav Orlenko <[email protected]> wrote:
>> >> � � �errors.add_to_base("Error message") unless cost.is_a?(Fixnum)
>> >>
>> >> when I enter 'asdf':
>> >>
>> >> ### 0: Fixnum
>> >>
>> >> I completely can't understand what happen. In migration:
>> >>
>> >> t.integer :cost
>> >>
>> >> I think ActiveRectord converts value to Fixnum because in migration
>> this
>> >> field signed as integer
>> >
>> > How is the string you enter getting into the cost attribute?
>> >
>> > Colin
>>
>> I can't understand why cost field value (10, 10.1 or 'asdf') all time is
>> Fixnum in model. In this model I try to validate cost, and can't because
>> all time I get only one type - Fixnum!
>> --
>> 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]<rubyonrails-talk%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>>
>

-- 
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