2006/3/5, Michael Koziarski <[EMAIL PROTECTED]>:
> On 3/6/06, Francois Beausoleil <[EMAIL PROTECTED]> wrote:
> > class Customer
> >   def tax_rate
> >     (read_attribute(:tax_rate) * 100.0).to_i
> >   end
> >
> >   def tax_rate=(rate)
> >     write_attribute(:tax_rate, rate / 100.0)
> >   end
> > end
>
> Otherwise the user's data will be 'randomly' changed by the system.   i.e.
>
> irb(main):001:0> "asdifjasdliofj".to_i
> => 0
> irb(main):002:0> "123,40".to_i
> => 123
>
> So if it didn't use _before_typecast, and the user typed either of
> those values, then when the page was re-rendered,  the values won't
> have been remembered correctly.

How can custom reader/writer methods be accomodated then ?

Thanks !
--
François Beausoleil
http://blog.teksol.info/
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to