我有一个 has_many 和 has_many :through 看起来像这样的关系......
class Guestlist < ActiveRecord::Base
belongs_to :venues
has_many :patrons
has_many :users, :through => :patrons
attr_accessible :capacity, :end_time, :name, :start_time, :venue_id
end
class Patron < ActiveRecord::Base
belongs_to :guestlists
belongs_to :users
attr_accessible :guestlist_id, :user_id, :checked_in
end
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
has_many :patrons
has_many :guestlists, :through => :patrons
end
我正在尝试“通过”访客列表对象访问用户...
@guestlist = Guestlist.find(params[:id])
@guests = @guestlist.users.order('name ASC')
并引发以下错误...
NoMethodError (undefined method `scoped' for Users:Module)
我一直在寻找解决方案,但没有任何效果。请帮忙!