I believe the type casting happens in the database adapter itself, for example, the MySQL adapter will do it, as would the Postgres one. <br><br><a href="http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Column.html#method-c-string_to_date">http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Column.html#method-c-string_to_date</a><br>
<br>You can always override the Model's accessor and do your own conversion in there? <br><br><div class="gmail_quote">On 26 July 2011 16:39, John Winters <span dir="ltr"><<a href="mailto:john@sinodun.org.uk">john@sinodun.org.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 26/07/11 16:07, John Winters wrote:<br>
[snip]<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
def read_attribute_before_type_<u></u>cast(attr_name)<div class="im"><br>
@attributes[attr_name]<br>
end<br>
<br>
Unless I've missed it somewhere, no formatting at all occurs.<br>
</div></blockquote>
<br>
I'm back to my earlier view that no formatting occurs in the field handling code, but there is some sort of conversion happening in ActiveRecord and I'm at a loss as to where.<br>
<br>
I have a model called an era, and it has a Date field called starts_at.  I've fire up the console and get the following (prompt shortened for clarity):<br>
<br>
> era.starts_at.class<br>
 => Date<br>
> era.attributes["starts_at"].<u></u>class<br>
 => Date<br>
> era.read_attribute_before_<u></u>type_cast("starts_at").class<br>
 => String<br>
<br>
Now where did that conversion occur?<div><div></div><div class="h5"><br>
<br>
John<br>
______________________________<u></u>_________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/<u></u>listinfo.cgi/chat-lrug.org</a><br>
</div></div></blockquote></div><br>