Reputation: 3
I am getting this error in Active Admin with rails 4.1
Showing ../bundler/gems/active_admin-ad33a0f6c772/app/views/active_admin/resource/index.html.arb where line #1 raised:
undefined method `call' for ClassList::ActiveRecord_Relation:0xa9f44bc
Extracted source (around line #1)
1 insert_tag renderer_for(:index)
Below is my code that I am using
ActiveAdmin.register ClassList do #.... scope :upcoming_classes #.... end
and in Model
class ClassList < ActiveRecord::Base scope :upcoming_classes, where('class_date > ?', Date.today) end
Please anyone help me in fixing this error?
Thanks,
Upvotes: 0
Views: 586
Reputation: 3363
You should define your scope using a proc
.
class ClassList < ActiveRecord::Base
scope :upcoming_classes, proc { where('class_date > ?', Date.today) }
end
Rails 4+ expects scopes to be wrapped with a callable object, which is usually defined as a proc
. See the Active Record Query Interface: Scopes documentation; there they use the -> { }
proc syntax.
Upvotes: 1