views:

181

answers:

1

I have a before_save that calculates a percentage that needs to include the object that is being updated. Is there a one-liner in Rails that takes care of this?

for example and this is totally made up:

Object.find(:all, :include => :updated_object)

Currently I'm sending the object that is getting updated to the definition that calculates the percentage and that works but it's making things messy.

A: 

I'm not sure what you're trying to do here - :include needs to be given the name or names of associations. Inside a before_save, the object that is being updated, ie is about to be saved, is simply 'self'.

If i'm missing the point can you edit your question to include some more code and a description of what you want to do?

Max Williams