We have a simple site model with single table inheritance sites(id, type, title, address) where type can be “Home” or “office”. When we were on Rails 2.3.5 we could do Site.last.title and it would give the title. However, on Rails 3.2.6, when we do Site.last.title it give us the value as the type column instead.
Is it possible to get the value of the title instead of the type?
If you are trying to get the newest value of a table, It is better to find it by
created_atcolumn. By default, usingSite.last, Rails will search by primary key (ID), which is fine most of the time. However, if for any reason you need to change anIDon an existing record, your SQL will not return what you expect.So, it is better to do something like:
Regarding the problem you are facing, I think the problem is related to the
typeand not thetitle. Anyway, I recommend you to set the newestsitein your controller and then call it in your view.I hope it helps…