Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Course model
- class Course < ActiveRecord::Base
- has_many :registrations
- has_many :orders, :through => :registrations, :uniq => true, :include => :user
- ...
- ## Registration model
- class Registration < ActiveRecord::Base
- belongs_to :course
- belongs_to :order
- ## Order model
- class Order < ActiveRecord::Base
- has_many :registrations
- has_many :courses, :through => :registrations
- belongs_to :user
- ## User model
- class User < ActiveRecord::Base
- attr_accessor :password_confirmation
- has_many :orders
- has_and_belongs_to_many :roles
- has_many :registrations, :through => :orders,
- :uniq => true,
- :include => :course
- ## Error
- >> Course.find :all, :select => 'distinct courses.*', :joins => {:registrations => {:orders => :user}}
- ActiveRecord::ConfigurationError: Association named 'orders' was not found; perhaps you misspelled it?
Add Comment
Please, Sign In to add comment