Created
March 30, 2011 14:12
-
-
Save elentras/894463 to your computer and use it in GitHub Desktop.
This file contains 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 Issue < ActiveRecord::Base | |
has_many :line_items, :as => :itemable | |
has_many :orders, :through => :line_items | |
end |
This file contains 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 LineItem < ActiveRecord::Base | |
belongs_to :order | |
belongs_to :itemable, :polymorphic => true | |
end |
This file contains 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 Offer < ActiveRecord::Base | |
has_many :line_items, :as => :itemable | |
has_many :orders, :through => :line_items | |
end |
This file contains 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 Order < ActiveRecord::Base | |
belongs_to :user | |
has_many :line_items | |
has_many :issues, :through => :line_items, :source => :itemable, :source_type => 'Issue' | |
has_many :offers, :through => :line_items, :source => :itemable, :source_type => 'Offer' | |
end |
This file contains 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 User < ActiveRecord::Base | |
belongs_to :user_session | |
has_many :orders, :conditions => "status = 'Completed'" | |
## Source de mes soucis : | |
has_many :issues, :through => :orders, :source => :issue, :conditions => "status = 'Completed'" | |
has_many :offers, :through => :orders, :source => :offer, :conditions => "status = 'Completed'" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment