Skip to content

Rails plugin that allows you to eager load polymorphic associations

License

Notifications You must be signed in to change notification settings

grnbeagle/polymorphic_include

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PolymorphicInclude
==================

Eager loading of polymorphic associations doesn't work in Rails <2.1 and
only works in 2.1 if rails doesn't have to fall back on left outer joins
for the :include.

This plugin allows eager loading in all situations in rails.

It assumes you are using the default "_type" suffix. With this code you can just
use a :include directive in your finds and it will return your associations
instead of throwing an exception.


Example
=======

Stolen from Rails documentation

class Address < ActiveRecord::Base
  belongs_to :addressable, :polymorphic => true
end

# A call that tries to eager load the addressable model
Address.find(:all, :include => :addressable)


Copyright (c) 2008 Jason Haruska, released under the MIT license

About

Rails plugin that allows you to eager load polymorphic associations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published