Skip to content

Instantly share code, notes, and snippets.

@AndrewO
Created September 24, 2008 17:36
Show Gist options
  • Save AndrewO/12618 to your computer and use it in GitHub Desktop.
Save AndrewO/12618 to your computer and use it in GitHub Desktop.
#project.rb
has_many :usages
has_many :asset_orders
has_many :usages, :through => :requests
#request.rb
belongs_to :project
#usage.rb
belongs_to :request
belongs_to :asset
has_and_belongs_to_many :asset_orders
#asset.rb
has_many_polymorphs :holdables, :from => [:clients, :vendors], :through => :licenses
#asset_order.rb
belongs_to :project
has_and_belongs_to_many :usages
#vendor.rb
has_many :licenses, :as => :holdable
#license.rb
belongs_to :vendor, :polymorphic => true
belongs_to :assets
Vendor.find(
:all,
:include => {:license => {:asset => {:usages => {:asset_orders}}}},
:conditions => "asset_orders.id IS NOT NULL"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment