I am getting this error while accessing scopes.
Here is AR model
class StatisticVariable < ActiveRecord::Base
attr_accessible :code, :name
ha
I got this error because one of my scopes was returning self, which I assumed was the relation object (didn't work); returning nil instead achieved the expected result. eg:
scope :except_ids, -> ids do
if ids.present?
ids = ids.split(',') if ids.respond_to?(:split)
where('id not in (?)', ids)
end
end
if ids.present? returns false, the condition returns nil and the scope has no effect, but is still chainable.