未定义的方法`搜索'对于#
我一直在控制器索引中获取上述NoMethodError,即使该方法存在于模型中。以下是我的模型和控制器。我在哪里弄错了?
控制器:
def index
@ratings = Clerk::Rating.search(params).paginate(:per_page => 10, :page => params[:page])
end
型号:
module Clerk
class Rating < Base
# Relationships
belongs_to :application
belongs_to :consumer
def self.search(params)
ratings = all
if params[:search].present?
ratings = ratings.joins(:consumer).where('phone like ? or lower(email) like ? or lower(first_name) like ? or lower(last_name) like ?',"%#{params[:search]}%","%#{params[:search].downcase}%","%#{params[:search].downcase}%","%#{params[:search].downcase}%")
end
ratings
end
end
end
答案 0 :(得分:0)
您是否已将模块包含在控制器中?
在类定义的正下方添加include Clerk
,然后重试该操作。