Not quite.  When your Era record is in memory it is a fully-fledged Era object, with all of its attributes type cast, so starts_at is a Date object.<br><br>The "magic" happens in the adapter, so to/from the object to the database.<br>

<br> > era.read_attribute_before_type_cast("starts_at").class<br>  => String<br><br>As far as I'm aware this is just basically a utility method, it does a lookup on the attribute before it was type cast (which was earlier stored before the type cast occurred).<br>
<br>I hope that helps clear it up slightly.<br>
<br><div class="gmail_quote">On Tue, Jul 26, 2011 at 5:10 PM, John Winters <span dir="ltr"><<a href="mailto:john@sinodun.org.uk" target="_blank">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:56, Liam McAndrew wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
John,<br>
<br>
I believe the clue is to look here:<br>
<a href="http://apidock.com/rails/ActiveRecord/AttributeMethods/read_attribute" target="_blank">http://apidock.com/rails/<u></u>ActiveRecord/AttributeMethods/<u></u>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" target="_blank">http://apidock.com/rails/<u></u>ActiveRecord/<u></u>ConnectionAdapters/Column/<u></u>type_cast</a><br>
<br>
Again view the source, the case statement refers to the 'type'<br>
attribute, which is actually an instance variable for the<br>
'simplified_type' method...<br>
<br>
<a href="http://apidock.com/rails/ActiveRecord/ConnectionAdapters/Column/simplified_type" target="_blank">http://apidock.com/rails/<u></u>ActiveRecord/<u></u>ConnectionAdapters/Column/<u></u>simplified_type</a><br>
<br>
And that's where the magic appears to happen!<br>
</blockquote>
<br>
Hah!  So, please correct me if I'm wrong here...<br>
<br>
When my Era record is sitting in memory, it actually contains my date as a string, say "2011-07-26" in the format in which it would expect to write it to the database.  Then whenever I try to access it by any normal method, it's automagically converted into a Date type.<br>


<br>
The magic that's happening in this instance is actually that it's *not* being converted.  The reason I couldn't see where the conversion took place is because - there is no conversion.<br>
<br>
Have I got it now?<br>
<br>
Cheers,<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>