Created
April 13, 2017 19:50
-
-
Save laspluviosillas/95c66a2976cd3fa52688c9e5a2f69e7b to your computer and use it in GitHub Desktop.
Issue with polymorphic associations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Task < ActiveRecord::Base | |
has_one :notification_preference, as: :notifee | |
end | |
class NotificationPreference < ActiveRecord::Base | |
belongs_to :notifee, polymorphic: true | |
end | |
# Code above keeps on looking for notifee_id on Task. | |
# The foreign keys are obviously in the NotificationPreference table (notifee_id and notifee_type) | |
# But I only want Task to have one associated notification preference. | |
# how do i do this? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment