I am getting this error while accessing scopes.
Here is AR model
class StatisticVariable < ActiveRecord::Base
attr_accessible :code, :name
has_many :statistic_values
scope :logins, where(code: 'logins').first
scope :unique_logins, where(code: 'unique_logins').first
scope :registrations, where(code: 'registrations').first
end
and when I try with StatisticVariable.logins
or any other scopes it gives:
NoMethodError: undefined method `default_scoped?'
If I configure scope as class method then it works perfectly.
def self.registrations
where(code: 'registrations').first
end
Please guide me to understand and fix this problem.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…