I have a book model in my Rails application with various properties (as well as columns in a db table of a book). One of these properties is "ranking."
Recently, an application can run NoMethodError: undefined method 'include?' for nil:NilClassfor the following code:
def some_method(book, another_arg)
return book.ranking unless book.ranking.blank?
...
end
However, this is incompatible. The vast majority of the time, turning to book works - an error occurs, perhaps in 2-4% of cases. If I change the code to book[:ranking]or book['ranking']instead book.ranking, it works 100% of the time.
Any ideas?
PS This problem occasionally occurred with other models and attributes ... and not just with the Book and Rank attribute.