github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

haruska / polymorphic_include

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 25
    • 4
  • Source
  • Commits
  • Network (4)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Rails plugin that allows you to eager load polymorphic associations — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

patch to be compatible with polymorphic includes present in scopes (e.g. 
named_scope :foo, :include => :polything; or will_paginate + squirrel) 
saizai (author)
Sun Nov 01 20:50:31 -0800 2009
commit  42de2079e44d36437a343d3955728d6a6c6b6257
tree    2da87577eadaf6628fb3d440740ec8da92071b2c
parent  5e6282e29e40c7aba4ebd45d963978ae0daa46c7
polymorphic_include /
name age
history
message
file .gitignore Loading commit data...
file MIT-LICENSE
file README.markdown
file Rakefile
file init.rb
directory lib/
directory test/
README.markdown

Polymorphic Include

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.

Installation

To install as a rails plugin, use the script/plugin command with rails >= 2.0

./script/plugin install git://github.com/haruska/polymorphic_include.git

For rails < 2.0, install it by hand

cd vendor/plugins
git clone git://github.com/haruska/polymorphic_include.git

Example Usage

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-2009 Jason Haruska, released under the MIT license

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server