UserNotification belongs_to User and User has_many UserNotification.
I am trying to access the notifications through the user. If I run in the console:
User.find(31).user_notifications
It returns the following user:
<Employer id: 31, email: "person1@commercial.com", ...>
The code above is correct (A user can be of type 'employer' or 'freelancer'. I believe this is called polymorphic). However, if I run:
User.where(email: 'person1@commercial.com').user_notifications
I am told that:
undefined method `user_notifications'
This should give me the same user as the 'find' method I use above. In my application, I am having the same problem referring to the user_notification when using current_user. For example, I have:
@notifications = current_user.user_notifications.inspect
I do this while logged in as the same user I was working with in the console, User 31. However, the user_notifications are displayed as nil.
How do I access user_notification through current_user?