I have a social dating Rails 4 website that triggered a Sentry error. In a search controller that returns the closest users within a certain radius:
The exception is NoMethodError undefined method `page' for nil:NilClass and is related to the following line of code:
current_user.longitude).users.page(params[:page]).per(20)
The referrer URL in this request was something.com/login and this request URL was something.com/search. The "page" method comes from the Kaminari gem, a pagination gem. The user logs in and is redirected to a profile page where they can click a "Search" button. My question is: what could possibly be triggering this error and/or why does /search have a referrer URL of /login? There's no search button on the login page. When I test everything manually, everything works as it should.
EDIT: The issue is that the referrer URL is /login on the /search action that is causing the error. However, a person logging in will not be directed to the search action they will be redirected to a profile page where they can then click on the Search button.
the problem is not in the
Kaminary, it says "undefined method for nil", which means, theusersmethod for some reason returnsnil, that's what you want to check