Having a similar issue to this guy: Rails 4 with has_scope: fails silently
But his answer didn't help my situation. I'm using the has_scope gem with the following code:
#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
Then using the url http://localhost:3000/inboxes/3?by_person=Meghan I get this error
undefined method `by_person' for #<Request::ActiveRecord_Relation:0x007fadf72a3148>
for this line
@requests = apply_scopes(Request.where(inbox_id: params[:id]).paginate(:page => params[:page], :per_page => 20))
Once I get it working with first name I'm going to move on to all other things to filter by. I appreciate any help or guidance in this situation!