Right now I have a model called Profile which is associated with a User (basically in Profile I save all the information associated with the User, and in User I store stuff like password, last_sign_in,…). I want to be able to send some (weekly) emails to the users and I was wondering on just adding a new column to the Profile table.
However, I think that it can happen that I want to send daily too, so I was thinking on creating a new table called “Notifications” that is associated with Profile. However, I fail to see which kind of association I should do.
A profile can have many notifications, but a kind of notification can be in many Profiles. How would you guys do that?
Thanks!
I think it depends exactly what you are trying to accomplish it sounds like you have a notifications type and also instances of notifications against profiles.
If this is the case then you’d typically have a one to many relationship a profile can have many notifications; in your Profile model include has_many => notifications. And each notification has a type reference; in your Notification model include belongs_to => profile and has_many => notification_types. Which means notification_type belongs to many notifications; in your NotificationType model include belongs_to => notifications.