Skip to content

Instantly share code, notes, and snippets.

@semanticart
Created November 21, 2008 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save semanticart/27439 to your computer and use it in GitHub Desktop.
Save semanticart/27439 to your computer and use it in GitHub Desktop.
class Child
belongs_to :master, :polymorphic => true
end
class HumanParent
has_many :organs
end
class RobotOverlord
has_many :spark_plugs
has_many :power_supplies
end
# i want each included master to eager-load their hm relationships, but this
# fails since HumanParent doesn't have spark_plugs, etc.
Child.all(:include => {:master, [:organs, :spark_plugs, :power_supplies]})
# as an epilogue, you can accomplish what I wanted to do by hacking activerecord
# to not raise the exception. It is super-easy to do (just see the stacktrace when
# you try to do this and remove that line), but I ended up approaching the problem
# from the other direction and not needing a hacky solution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment