I think the only way you want to format it is for display to the end
user, store it in the database in a different format.

On 5/25/07, Josh Susser <[EMAIL PROTECTED]> wrote:
>
> That takes care of the transformation in one direction, but not the
> other.  I suppose you can just handle that the usual way with a
> before_validation callback.  Sorry if that's silly, I haven't been
> following this thread in detail.
>
> --josh
>
> On May 24, 2007, at 10:22 PM, Nik Wakelin wrote:
>
> > How about this for a solution.
> >
> > The real problem seems to be that people want to format attributes
> > before they display them (credit card, phone number). So, how about we
> > allow that. Could be as simple as:
> >
> >  <%= text_field :person, :name, :formatter => :random -%>
> >
> >  class Person < ActiveRecord::Base
> >
> >    def random(value)
> >       value.upcase * 4
> >    end
> >
> >  end
> >
> > Thoughts?
> >
> > On 5/23/07, Mislav Marohnić <[EMAIL PROTECTED]> wrote:
> >> On 5/23/07, Nik Wakelin <[EMAIL PROTECTED]> wrote:
> >>>
> >>>   1) If an overridden accessor is there, (i.e you've defined
> >>> Product#price) then that gets called
> >>>    2) Otherwise, we call price_before_type_cast
> >>
> >> That's still no good. You want to be able to display to the user
> >> exactly
> >> what he entered, unconditionally. Doing what you suggested would
> >> make the
> >> behavior even more inconsistent.
> >>
> >>
> >>>
> >>
> >
> >
> > --
> > Nik Wakelin
> > (027) 424 5433
> > [EMAIL PROTECTED]
> >
> > >
>
> --
> Josh Susser
> http://blog.hasmanythrough.com
>
>
>
> >
>


-- 
Nik Wakelin
(027) 424 5433
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to