Created
May 31, 2011 17:55
-
-
Save resistorsoftware/1000968 to your computer and use it in GitHub Desktop.
how to write AR query to just show orders with a delivery date for an item
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UnfulfilledOrder < ActiveRecord::Base | |
| belongs_to :shop | |
| has_many :items, :dependent => :delete_all | |
| end | |
| class Item < ActiveRecord::Base | |
| belongs_to :unfulfilled_orders | |
| has_many :deliveries, :dependent => :delete_all | |
| end | |
| class Delivery < ActiveRecord::Base | |
| belongs_to :items | |
| def self.has_delivery? date | |
| find_by_delivery_date(date) | |
| end | |
| def self.current date | |
| where("delivery_date = ? ", date) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment