次のコードがあるとします。
user_decorator.rb
Refinery::User.class_eval do
has_many :employees, :class_name => 'Refinery::Employee'
scope :active_employees,
lambda {
joins(:employees).merge(::Refinery::Employee.active)
}
end
従業員.rb
module Refinery
class Employee < ActiveRecord::Base
belongs_to :user, :class_name => 'Refinery::User'
scope :active, where(:retired => false)
end
end
Railsコンソールを実行しています...
> ::Refinery::User.active_employees
=> [ .......... lots of records etc ]
> user = ::Refinery::User.where(:username => 'test').first
=> #<Refinery::User .... etc etc>
> user.active_employees
NoMethodError: undefined method `active_employees' for #<Refinery::User:0x000000051330f8>
私は何を間違っていますか?