对这个人有类似的问题:Rails 4 with has_scope: fails silently
但他的回答对我的情况没有帮助。我正在使用带有以下代码的has_scope gem:
<xsl:if test="$occupation contains('5','7','N','W','J','M')">
然后使用网址http://localhost:3000/inboxes/3?by_person=Meghan我收到此错误
#model
class Inbox < ActiveRecord::Base
has_paper_trail
has_many :requests
belongs_to :match_rule
scope :by_person, -> person { where(Request.where(inbox_id: params[:id]).person[:first_name] => person) }
end
#controller
class InboxesController < ApplicationController
before_action :authorize
before_action :set_inbox, only: [:show, :edit, :update, :destroy]
before_filter :set_paper_trail_whodunnit
has_scope :by_person
def show
@requests = apply_scopes(Request.where(inbox_id: params[:id]).paginate(:page => params[:page], :per_page => 20))
end
private
def set_inbox
@inbox = Inbox.find(params[:id])
end
这一行
undefined method `by_person' for #<Request::ActiveRecord_Relation:0x007fadf72a3148>
一旦我使用名字,我将继续进行所有其他事情的过滤。在这种情况下,我感谢任何帮助或指导!