ruby-on-railsrubysunspot

sunspot parameters transferring


I have a little problem with the sunspot. I have a model with fields

:country_id
:city_id

both are integers. And

:title

is string

I have, in model.rb

searchable do
    text :title
    integer :country_id
    integer :city_id
  end

and

@search = Page.solr_search do
      fulltext params[:title]
      with(:country_id,params[:country_id])
      with(:city_id,params[:city_id])

    end

in controller.

But sunspot don't want to work, it work only without

          with(:country_id,params[:country_id])
          with(:city_id,params[:city_id])

params[:city_id] and params[:country_id] are passed correctly, so problem is not with them. What am I doing wrong?


Solution

  • Your configuration seems good to me, do a re-indexing and try following,

       @search = Page.solr_search do
          fulltext params[:title]
          with :country_id, params[:country_id].to_i
          with :city_id, params[:city_id].to_i    
        end