Skip to content

Instantly share code, notes, and snippets.

@tanordheim
Created November 22, 2010 21:33
Show Gist options
  • Save tanordheim/710739 to your computer and use it in GitHub Desktop.
Save tanordheim/710739 to your computer and use it in GitHub Desktop.
>> Organization.order("name asc").limit(5).includes([ :web_presence, :billing_address, :shipping_address, :contact_info ])
Organization Load (0.4ms) SELECT "organizations".* FROM "organizations" ORDER BY name asc LIMIT 5
ShippingAddress Load (0.3ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'ShippingAddress') AND ("addresses".addressable_id = 51 AND "addresses".addressable_type = 'Organization') LIMIT 1
BillingAddress Load (0.3ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'BillingAddress') AND ("addresses".addressable_id = 51 AND "addresses".addressable_type = 'Organization') LIMIT 1
ContactInfo Load (0.2ms) SELECT "contact_infos".* FROM "contact_infos" WHERE ("contact_infos".contactable_id = 51 AND "contact_infos".contactable_type = 'Organization') LIMIT 1
WebPresence Load (0.3ms) SELECT "web_presences".* FROM "web_presences" WHERE ("web_presences".presenceable_id = 51 AND "web_presences".presenceable_type = 'Organization') LIMIT 1
ShippingAddress Load (0.4ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'ShippingAddress') AND ("addresses".addressable_id = 57 AND "addresses".addressable_type = 'Organization') LIMIT 1
BillingAddress Load (0.2ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'BillingAddress') AND ("addresses".addressable_id = 57 AND "addresses".addressable_type = 'Organization') LIMIT 1
ContactInfo Load (0.2ms) SELECT "contact_infos".* FROM "contact_infos" WHERE ("contact_infos".contactable_id = 57 AND "contact_infos".contactable_type = 'Organization') LIMIT 1
WebPresence Load (0.3ms) SELECT "web_presences".* FROM "web_presences" WHERE ("web_presences".presenceable_id = 57 AND "web_presences".presenceable_type = 'Organization') LIMIT 1
ShippingAddress Load (0.2ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'ShippingAddress') AND ("addresses".addressable_id = 53 AND "addresses".addressable_type = 'Organization') LIMIT 1
BillingAddress Load (0.4ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'BillingAddress') AND ("addresses".addressable_id = 53 AND "addresses".addressable_type = 'Organization') LIMIT 1
ContactInfo Load (0.3ms) SELECT "contact_infos".* FROM "contact_infos" WHERE ("contact_infos".contactable_id = 53 AND "contact_infos".contactable_type = 'Organization') LIMIT 1
WebPresence Load (0.4ms) SELECT "web_presences".* FROM "web_presences" WHERE ("web_presences".presenceable_id = 53 AND "web_presences".presenceable_type = 'Organization') LIMIT 1
ShippingAddress Load (0.3ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'ShippingAddress') AND ("addresses".addressable_id = 83 AND "addresses".addressable_type = 'Organization') LIMIT 1
BillingAddress Load (0.2ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'BillingAddress') AND ("addresses".addressable_id = 83 AND "addresses".addressable_type = 'Organization') LIMIT 1
ContactInfo Load (0.2ms) SELECT "contact_infos".* FROM "contact_infos" WHERE ("contact_infos".contactable_id = 83 AND "contact_infos".contactable_type = 'Organization') LIMIT 1
WebPresence Load (0.3ms) SELECT "web_presences".* FROM "web_presences" WHERE ("web_presences".presenceable_id = 83 AND "web_presences".presenceable_type = 'Organization') LIMIT 1
ShippingAddress Load (0.2ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'ShippingAddress') AND ("addresses".addressable_id = 66 AND "addresses".addressable_type = 'Organization') LIMIT 1
BillingAddress Load (0.4ms) SELECT "addresses".* FROM "addresses" WHERE ("addresses"."type" = 'BillingAddress') AND ("addresses".addressable_id = 66 AND "addresses".addressable_type = 'Organization') LIMIT 1
ContactInfo Load (0.3ms) SELECT "contact_infos".* FROM "contact_infos" WHERE ("contact_infos".contactable_id = 66 AND "contact_infos".contactable_type = 'Organization') LIMIT 1
WebPresence Load (0.2ms) SELECT "web_presences".* FROM "web_presences" WHERE ("web_presences".presenceable_id = 66 AND "web_presences".presenceable_type = 'Organization') LIMIT 1
class Organization < ActiveRecord::Base
has_one :shipping_address, :as => :addressable
has_one :billing_address, :as => :addressable
has_one :contact_info, :as => :contactable
has_one :web_presence, :as => :presenceable
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment