I think the new functionality in edge rails will do what you want:

http://afreshcup.com/2009/04/19/touch-your-active-record-instances/

You say:

class Photo
  belongs_to :user, :touch => true
end

This way, whenever you save or delete a photo instance, it'll 'touch' 
its parent user, and update the updated_at timestamp.

This will require you to upgrade to edge rails, though.

Looking at your attempt, though, I'm not sure this is what you want. Are 
you also using the "updated_by" attribute of the photo to save the id of 
the user that changed it?

Chris




Carlos Santana wrote:
> I have nested resources as follows: 'albums has_many photos'.
> Whenever someone edits photos, I would like update time stamp on albums.
> I tried to do this like:
> @photos.albums.updated_by = @currentusername
> @photos.albums.save
> 
> But, this is not updating albums. I don't see anything happening in the
> database log or mongrel log.
> 
> -
> CS.

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to