I have a problem with using sunspot_solr. I have an application that does some searches using this gem. There are 5 models that have this function, only 1 of them shows an error in
@search.results NoMethodError (undefined method `result=' for nil:NilClass): app/controllers/financial_dashboards_controller.rb:27:in `index'
Here is my code:
controller
@search = Sunspot.search(Purchase) do fulltext params[:search] with(:product_owner).equal_to(current_user.id) facet(:status) if params[:status].present? with(:status).equal_to(params[:status]) end facet(:sell_date) if params[:sell_date].present? with(:sell_date).equal_to(params[:sell_date]) end order_by(:sell_date, :desc) end
Model (Buying):
searchable do text :product_name text :product_short_description integer :product_owner string :status string :sell_date end def product_name product.name end def product_short_description product.short_description end def product_owner product.user.id end def sell_date date.to_s(:year_month) end
Another weird thing: on my development machine, this code works fine. On a production machine using nginx, the code displays this error.
I checked the gemstones version and they match. I tried
rake sunspot:solr:reindex RAILS_ENV=production
for reindexing. I tried
rake sunspot:solr:stop RAILS_ENV=production rake sunspot:solr:start RAILS_ENV=production
to restart the search server. Even tried to remove the solr / folder and let the start script copy it again.
And why do other models work fine? Any ideas how to solve this?
thanks
source share