John,<br><br>I believe the clue is to look here: <a href="http://apidock.com/rails/ActiveRecord/AttributeMethods/read_attribute">http://apidock.com/rails/ActiveRecord/AttributeMethods/read_attribute</a><br><br>View the source and note the 'column.type_cast' line...<br>
<br><a href="http://apidock.com/rails/ActiveRecord/ConnectionAdapters/Column/type_cast">http://apidock.com/rails/ActiveRecord/ConnectionAdapters/Column/type_cast</a><br><br>Again view the source, the case statement refers to the 'type' attribute, which is actually an instance variable for the 'simplified_type' method...<br>
<br><a href="http://apidock.com/rails/ActiveRecord/ConnectionAdapters/Column/simplified_type">http://apidock.com/rails/ActiveRecord/ConnectionAdapters/Column/simplified_type</a><br><br>And that's where the magic appears to happen!<br>
<br>Liam.<br><br><div class="gmail_quote">On Tue, Jul 26, 2011 at 4:39 PM, 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: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On 26/07/11 16:07, John Winters wrote:<br>
[snip]<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
def read_attribute_before_type_<u></u>cast(attr_name)<br>
@attributes[attr_name]<br>
end<br>
<br>
Unless I've missed it somewhere, no formatting at all occurs.<br>
</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?<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>
</blockquote></div><br>