Rails 4 Sunspot Facets: Undefined method split

23 views
Skip to first unread message

Af Dig

unread,
Feb 21, 2016, 7:46:16 PM2/21/16
to Sunspot
I am trying to use facets with a job model. This is my code:

Model: Job - searchable

   
searchable do
        text
:name, :boost => 5
        text
:description
        text
:subcategory
        integer
:subcategory_id, references: :subcategory
   
end


Controller: Index Action


   
def index
     
if params[:q]
     
@search = Job.search do
         keywords
params[:q] do
          highlight
:name, :description
         
end
         
with(:subcategory_id)
         facet
(:subcategory_id)
     
end
       
@jobs = @search.results
     
else
     
@jobs = Job.all.order('created_at desc')
     
end


     
@job = Job.new
   
end


View Index + Search Results Page

   
%ul.facet
     
- @search.facet(:subcategory_id).rows.each do |row|
       
= link_to row.instance.name, url_for(subcategory_id: row.value)
       
= "(#{row.count})"

   
I am now getting an error that says 

"undefined method `split' for :subcategory:Symbol"

Where am I going wrong? Job - searchable

Reply all
Reply to author
Forward
0 new messages