[LRUG] How does Rails decide how to parse ambiguous dates?
John Winters
john at sinodun.org.uk
Wed Jul 27 01:42:12 PDT 2011
On 27/07/11 09:30, Paul Robinson wrote:
> On 26 Jul 2011, at 17:43, John Winters wrote:
>
>> Yes, that's a nice idea, but it still leaves unanswered the question of how to get an existing date formatted like that in the text field.
>
>
> Wait, what?
>
> Your database column is a date type right? Not just a varchar?
Yes, it's a date type.
> So by "text field" I'm assuming you mean the text input on the form.
Yes.
> But the Rails i18n helpers should look after that for you. So what is it specifically that isn't working?
As far as I can discover, the Rails i18n helpers don't touch the content
of a field. I've been doing some web searching and found others with
the same problem. I've also dug through the code (as documented in this
thread) and as far as I can see, there is no code to apply
internationalisation to the contents of a field.
The text_field code gets its contents by calling
<attribute_name>_before_type_cast on the model and putting the result
straight into the field. It's already a string by the time the model
hands it over to the field code.
I'm open to correction if you can find some code which applies
formatting to the contents of such a field. I'm very much a novice at
Ruby and Rails (but quite an experienced software developer).
Cheers,
John
More information about the Chat
mailing list