I'm using Rails 4 and am trying to implement a Notif
model which should have an array of users that have seen it.
My idea is to use a has_many relationship (notif has_many :users
) where I add users which have seen the notif to the users
. The current issue I'm experiencing is that I cannot call @notif.users
because it states column users.notif_id does not exist
since I'm not using a belongs_to
.
One solution is to use a many-to-many relationship; however, I'd like to avoid having to create an individual association for each user that views a notification (trying to save database space).
Is there a way to effectively have a users
field without the has_many
relationship? I guess I'm simply trying to store an array of user ids in my notif model.