On 8 January 2011 04:06, Evan <evancha...@gmail.com> wrote:
> Is there a way to manipulate the attributes of an ActiveRecord-based
> model after it is retrieved from the database but before it is
> returned from the finder?
>
> I have tried defining an after_find callback method but was unable to
> access attributes that come from the database from this method. I
> tried accessing them using self.an_attribute and read_attribute but
> both raised an attribute exception.

I think that if you implemented after_find and did find all that it
would have to run through the whole set, so would presumably take 12
hours.  Maybe you do not do a find all, or even a find many, in which
case it should be able to work.

>
> I am trying to execute an upgrade-in-place strategy. When I deploy the
> latest version of my app one of the attributes on every existing
> record of a particular table will no longer be usable until converted
> to a new format. Rather than take the app down for 12 hours to upgrade
> the existing data I thought it could be upgraded on-access.

An alternative might be to do the test/upgrade in the access method(s)
for whatever attribute(s) are affected.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to