Question

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,

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top