I have a Rails 5 web app (almost). I want to include an attribute on all my views. I read somewhere that the way to do this was to define a helper method in my application controller, so I defined
class ApplicationController < ActionController::Base
before_action :store_last_page_visited
protect_from_forgery with: :exception
helper_method :unvoted_people
...
def unvoted_people
@unvoted_people = People.find_most_voted(current_user)
end
I only have an application layout for all my pages, yet in my view the logic after
<% if @unvoted_people %>
never gets called, even though I know the query should return results. What's the right way to include a model attribute that all my views can access?