How to update attribute belonging to other object

Hi, I’m working on a project management application

I have projects, wich consists of features which in turn consist of tasks.

The problem I’m facing is when a task or feature gets updated, the updated_at property of the project object should be updated as well. So whenever a task or feature gets updated, the update_at property of the project object should be set.

I’m not quite sure how to handle this, any suggestions are welcome.

greetings,

Anthony

You can set touch: true on the belong_to association:

http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-belongs_to

2 Likes

Hi andyw8

thanks a lot, I added

touch: true

to both the feature and task models, and now everytime a feature or task gets updated, it is reflected in the project updated at field.

greetings,

Anthony