Created
November 21, 2013 22:26
-
-
Save kshsieh/7590889 to your computer and use it in GitHub Desktop.
dual polymorphic joins table
This file contains hidden or 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 Groupable | |
has_many :group_rules, as: :grouped | |
has_many :rule_objects, through: :group_rules | |
end | |
class GroupRules | |
belongs_to :grouped, polymorphic: true | |
belongs_to :rulable, polymoprhic: true | |
end | |
class Country | |
has_many rules, as: :rulable | |
end | |
# trying to end up with something like groupable.rule_objects return an array of objects like Country, State, City, or Residency that can match up against a user | |
# but getting an error ActiveRecord::HasManyThroughAssociationPolymorphicSourceError: Cannot have a has_many :through association 'Groupable#rule_objects' on the polymorphic object 'Rulable#rulable'. |
ScotterC
commented
Nov 21, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment