I have a Book model in my Rails application, with various properties (aka columns in the book db table). One of these properties is "ranking".
Recently, may app has started to throw NoMethodError: undefined method 'include?' for nil:NilClass
for the following code:
def some_method(book, another_arg)
return book.ranking unless book.ranking.blank?
...
end
However, it's not consistent. The vast majority of the time, accessing book.ranking works -- the error is thrown maybe 2-4% of the time. If I change the code to book[:ranking]
or book['ranking']
instead of book.ranking
, it works 100% of the time.
Any ideas?
P.S. This problem has popped up intermittently with other models and attributes... not just Book and the ranking attribute.