Skip to content

Instantly share code, notes, and snippets.

@jashmenn
Created March 4, 2009 21:03
Show Gist options
  • Save jashmenn/74002 to your computer and use it in GitHub Desktop.
Save jashmenn/74002 to your computer and use it in GitHub Desktop.
class Order
has_many :order_order_properties, :dependent => :destroy,
:attributes => true
has_many(:properties, :class_name => "OrderProperty",
:through => :order_order_properties,
:source => :order_property)
named_scope :with_property_value, lambda { |property_name, value|
{
:include => [:properties, :order_order_properties],
:conditions => ['order_properties.name = ? AND order_order_properties.value = ?', property_name, value]
}
}
...
end
# orders = Order.with_property_value("order_motion_order_id", order_number)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment