Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Issue with polymorphic associations
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
You can’t perform that action at this time.