Hi,
Maybe more concrete:
I have a model with an attribute called "ammount". It''s a
price stored
in an integer (in cents). Is it possible to extend the to_s method for
that attribute? So that I will show " 20,00" when I do: <%=
ammount
%>
On Mar 30, 1:28 am, "LeonB"
<l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org>
wrote:> Hi!
>
> I''m developing an localization plugin (just for my own purposes)
and I
> wanted to extend the to_s method for the Time class.
>
> What I want to do:
> when someone does date.to_s(:short) that a localized version of
> the :short date is displayed.
> But I don''t know how to accomplish this. I know have this:
>
> class Time
> def to_s(option)
> print option.to_yaml
> ''lalo''
> end
> end
>
> Jepp... it prints all the the times to ''lalo'' :)
>
> But how do I adjust this method so that only in the case of :short the
> return value is modified?
> Something like:
>
> if option == :short {
> return self.strftime("%Y %D %E")
>
> }
>
> Or is there more to it?
>
> Thanks in advance!
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---