I can not figure out how to fix this issue!!! Please help!!
"undefined method `description' for nil:NilClass"
results with the following code:
<ul>Test Search:
<% @optsolr.each do |c| %>
<li>
<%= c.description %>
</li>
<% end %>
</ul>
When I only call “c” instead of c.description the result is:
Test Search:
" [#<Nmodel id: 44, name: nil, price: nil, expiration: "2012-02-22", category: "Life ", description: "my description text", user_id: 3, created_at: "2012-02-22 04:20:48", updated_at: "2012-02-22 04:20:48", quantity: nil>]"
My controller where i loop through a set of search parameters and search for a specific category:
@search = Nmodel.search do
fulltext o.category do
query_phrase_slop 16
end
end
@optsolr[count[ = @search.results
Results from rails debug:
—
– !!null
– !!null
– – !ruby/object:Nmodel
attributes:
id: 44
name: !!null
price: !!null
expiration: 2012-02-22
category: ! ‘Life ‘
description: my description text
user_id: 3
created_at: 2012-02-22 04:20:48.048506000Z
updated_at: 2012-02-22 04:20:48.048506000Z
quantity: !!null
I guess from this
Results from rails debug: --- - <<<<!!null >>>>>- <<<<!!null>>>>> - - <<<<!ruby/object:Nmodel attributes: id: 44.. it returning two empty record and one valid record.Try this.