Has_many association after_load type callback?

For anyone interested, in the end I delved into ActiveRecord and came up with the following: has_many :messages, :class_name => 'MyMessage', :finder_sql =>'SELECT * FROM messages WHERE receiver_id = #{id} OR sender_id = #{id}', :after_add => :set_user do def find_target messages = super messages. Each {|m| m. Principal_user = proxy_owner} messages end end.

Ideally this would behave exactly like an active_record has_many association. I decided to subclass the message model, aiming to create something that could respond in this way - it didn't seem appropriate to just add the methods to the Message class, as the object needs to have some knowledge of its 'principal individual' (in the case above @bob) in order to know which Message to create. This does almost what I want.

Unfortunately the after_add callback fires only when new objects are added to the messages collection, not when each object is loaded into the association for the first time. As far as I've found no 'after_load' association callback exists. Is there something else I can use, or a better way to approach this situation?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions