从rails 4.0.0升级后,Rails 4.1.0未定义的方法`call'

时间:2015-05-02 07:43:48

标签: ruby-on-rails ruby ruby-on-rails-4 activerecord ruby-on-rails-4.1

您好我已经从rails 4.0.0升级到Rails 4.1.0

现在我收到了这个错误:

enter image description here

删除时

.active

它有效...但为什么?我该如何解决这个问题?

course.rb

  self.inheritance_column = :_type_disabled
  has_and_belongs_to_many :clients, :join_table => :clients_courses  # TODO c
  has_many :memberships, :dependent => :destroy
  has_many :users, :through => :memberships

  has_many :lessons,
        -> {order "lessons.sort ASC, lessons.start_date"},
        :dependent => :destroy,
        :foreign_key => :course_object_id

  scope :active, where(:active => true)
  scope :inactive, where(:active => false)

2 个答案:

答案 0 :(得分:2)

Change you course.rb code to

  scope :active, -> { where(:active => true) }
  scope :inactive, -> { where(:active => false) }

答案 1 :(得分:2)

course.rb中的

You should provide lambda to the scope

scope :active, -> { where active: true }
scope :inactive, -> { where active: false }