I have several elements that are needed in each view and trying to set them in the application controller (which doesn’t work)…
class ApplicationController < ActionController::Base
protect_from_forgery
@top_categories = Category.top.limit(10)
end
How could I make that global data available in all views?
You could wrap that in a function and specify as a helper for example:
This will be available in all views and controllers