在通过另一个迁移从学生迁移中删除两个字段中间名、姓氏后,我面临以下错误。以下是错误。
Searchlogic::NamedScopes::OrConditions::UnknownConditionError in StudentController#advanced_search
条件“last_name”不是有效条件,我们找不到与此匹配的任何范围。
RAILS_ROOT: /root/ansipro342
Application Trace | Framework Trace | Full Trace
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/named_scopes/or_conditions.rb:96:in `interpolate_or_conditions'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/named_scopes/or_conditions.rb:75:in `each'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/named_scopes/or_conditions.rb:75:in `interpolate_or_conditions'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/named_scopes/or_conditions.rb:36:in `or_conditions'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/named_scopes/or_conditions.rb:19:in `or_condition?'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/named_scopes/or_conditions.rb:10:in `condition?'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/scopes.rb:10:in `scope?'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/method_missing.rb:16:in `method_missing'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/conditions.rb:19:in `send'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/conditions.rb:19:in `conditions='
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/conditions.rb:15:in `each'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/conditions.rb:15:in `conditions='
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/date_parts.rb:19:in `conditions='
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/base.rb:18:in `initialize'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/implementation.rb:10:in `new'
/root/ansipro342/vendor/plugins/searchlogic/lib/searchlogic/search/implementation.rb:10:in `search'
/root/ansipro342/app/controllers/student_controller.rb:816:in `advanced_search'
要求
参数:
{"search"=>{"order"=>"", "first_name_or_middle_name_or_last_name_or_admission_no_like"=>"Imran"}, "commit"=>"Search"}
以下是学生控制器中存在第 816 行的代码区域
def advanced_search
@search = Student.search(params[:search])
unless params[:search].present?
@batches = Batch.all
else
if params[:search].present?
@students = Array.new
if params[:advv_search].present? and params[:advv_search][:course_id].present?
unless params[:search][:batch_id_equals].present?
params[:search][:batch_id_in] = Batch.find_all_by_course_id(params[:advv_search][:course_id]).collect{|b|b.id}
end
end
if params[:search][:is_active_equals]=="true"
@students = Student.ascend_by_first_name.search(params[:search]).paginate(:page => params[:page],:per_page => 30)
elsif params[:search][:is_active_equals]=="false"
@students = ArchivedStudent.ascend_by_first_name.search(params[:search]).paginate(:page => params[:page],:per_page => 30)
else
@students = [{:student => {:search_options => params[:search], :order => :first_name}},{:archived_student => {:search_options => params[:search], :order => :first_name}}].model_paginate(:page => params[:page],:per_page => 30)#.sort!{|m, n| m.first_name.capitalize <=> n.first_name.capitalize}
end
@searched_for = ''
@searched_for += "<span>#{t('name')}/#{t('admission_no')}: " + params[:search][:first_name_or_admission_no_like].to_s + "</span>" if params[:search][:first_name_or_admission_no_like].present?
@searched_for += "<span>#{t('name')}: " + params[:search][:first_name_like].to_s + "</span>" if params[:search][:first_name_like].present?
@searched_for += " <span>#{t('admission_no')}: " + params[:search][:admission_no_equals].to_s + "</span>" if params[:search][:admission_no_equals].present?
if params[:advv_search].present? and params[:advv_search][:course_id].present?
course = Course.find(params[:advv_search][:course_id])
batch = Batch.find(params[:search][:batch_id_equals]) unless (params[:search][:batch_id_equals]).blank?
@searched_for += "<span>#{t('course_text')}: " + course.full_name + "</span>"
@searched_for += "<span>#{t('batch')}: " + batch.full_name + "</span>" if batch.present?
end
请帮助我不知道 last_name 存在于哪里,它的显示错误,我对 ruby on rails 很陌生,重要的是需要这个。
提前致谢。