I appreciate your reply, but your method does not always work.
If there has been a newly created associated record, the
before_update_save does not know about the new associated record until
after the associated record is created.  The associated record seems
to be created sometime after the before_update_save is run.  We are
also talking here about a through relationship where I'm working with
the join table and setting an attribute on the join table, and setting
the associated record to the join table.  It would just be far more
simple and easier for ActiveScaffold to run the AS call backs on the
associated model.  Also, the code I want to run has nothing to do with
the join table, but is specific to the associated record its self.
The solution I found yesterday is to look at the params. If there is
record[association][id] parameter, then I assume new association
record.  I set a session variable that gets checked in the
after_update_save.  I'm still having trouble with this method actually
saving the associated record, but it is about the only logical
alternative at this point.
I should also mention that I am running rails 2.3.2
Any further thoughts on this?
Thanks a million.

On Jun 16, 5:53 pm, "G. Sobrinho" <[email protected]> wrote:
> You can use before_update_save from top controller and call rails methods to
> get associated records. I used it on my application:
> def before_save_create(record)
>   record.users.each do |user|
>     user.role_id = x
>   end
> end
>
> But if you have to call the associated controller method, i think you need
> to create a static method on associated controller which you call it and
> before_update_save on that controller also.
>
> 2009/6/16 cntrytwist <[email protected]>
>
>
>
> > It appears that ActiveScaffold does not call the before_update_save/
> > before_create_save callbacks for associations.
> > What is the best way to make this happen?
> > I have an association in which I need to set some fields on the
> > associated record when it is created.  The issue is that I don't know
> > how to tell if the associated record is new or if it is just being
> > updated.  If ActiveRecord would issue the callbacks for the associated
> > records, I'd be just fine.
> > Please advise me of the best way to handle this.
> > Thanks in advance.
>
> --
> Regards,
>
> Gabriel Sobrinho
> E-mail: [email protected]
> Phone: +55 31 8775 8378
>
> Don't print this e-mail. The nature is thankful and your money also.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to