I was recently having problems accessing attributes in an object. Can
somebody explain to me why this is, and if it is a bug?
I have the following code:
@archives = RapturePost.find_by_sql “select distinct
date_format(rapture_posts.date_created,’%Y-%m’) date_created from
rapture_posts where rapture_posts.site_id = 1 order by
I wish to loop through the contents of the object with the following:
for archive in archives
#do something with the contents of archive
Whenever I try to access archive.date_created I get nothing.
For some reason the “distinct
date_format(rapture_posts.date_created,’%Y-%m’) as date_created” is
causing the date_created to become inaccessible.
When I loop through the @archives variable and do a debug I get:
… which shows the dates that I need.
However, when I attempt to access archive.date_created inside the loop,
it delivers me an empty string. This does not occur if I remove the
quoted section above and just select date_created; but obviously, I need
that date formatted clause.