[EMAIL PROTECTED] wrote:
> i read the  AS documentation and found that it recommends creating a
> virtual attribute in household.rb, of the form:
>
> def name
>       "#{self.user.name}"
> end
>
> so far so good...
>
> now i want to be able to update household.user.name when updating a
> household. so, i added a write accessor to household.rb:
>
> def first_name=(name)
>       self.user.first_name = name
> end
>
> my updates were silently failing. then i realized that, not
> surprisingly, AS is doing a household.save somewhere, but is not doing
> a household.user.save. so, i added the save to my write accessor:
>
> def first_name=(name)
>       self.user.first_name = name
>       self.user.save
> end
>   


All is working as intended here.  So you need to trigger your own save
code somewhere - question is where is best...

I suggest that you could hook into either the AS save event OR the
active record save callbacks and do the edit there.  These will slightly
delay the updates to a time closer to the main save

Note that there is a transaction around the save of an AS model
including callbacks so doing your updates in that stage are helpful if
you are using a transactional database

Good luck

Ed W

--~--~---------~--~----~------------~-------~--~----~
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