Note that there are some explanatory texts on larger screens.

plurals
  1. POsunspot_solr - NoMethodError (undefined method `result=' for nil:NilClass)
    primarykey
    data
    text
    <p>I have a problem related to the use of sunspot_solr. I have an application that performs some searches using this gem. There are 5 models that has this feature, only 1 of them is showing an error in</p> <pre><code> @search.results NoMethodError (undefined method `result=' for nil:NilClass): app/controllers/financial_dashboards_controller.rb:27:in `index' </code></pre> <p>Here is my code:</p> <p>Controller</p> <pre><code>@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 #line 27 @sales = @search.results.paginate(:page =&gt; params[:page], :per_page =&gt; 5) </code></pre> <p>Model (Purchase):</p> <pre><code>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 #indicates status of the payment and delivery def status() if !self.closed.nil? I18n.t('purchases.status.finished') elsif !self.measured.nil? I18n.t('purchases.status.measured') elsif !self.accomplished.nil? I18n.t('purchases.status.delivered') elsif !self.paid.nil? I18n.t('purchases.status.paid') elsif !self.canceled.nil? I18n.t('purchases.status.canceled') elsif !self.date.nil? I18n.t('purchases.status.waiting_payment') end end </code></pre> <p>Another strange thing is that on my development machine, this code works perfectly. On production machine that uses nginx, the code displays this error.</p> <p>I checked the version of gems and they match. I tried </p> <pre><code>rake sunspot:solr:reindex RAILS_ENV=production </code></pre> <p>to reindex. I tried</p> <pre><code>rake sunspot:solr:stop RAILS_ENV=production rake sunspot:solr:start RAILS_ENV=production </code></pre> <p>to restart the search server. Even tried to remove solr/ folder and let the start script copy it again. </p> <p>And why the other models work perfectly? Any ideas how to solve this?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload