I am using Ruby on Rails 3 and I am trying to use middlewares to set a variable @variable_namethat is available later in controllers.
For example, my middleware
class Auth
def initialize(app)
@app = app
end
def call(env)
@account ||= Account.find(1)
@app.call(env)
end
end
The above code sets the variable correctly @accountbut is not available in my application (in controllers, models, views ...). So how can I do this?
I saw this answer , which is a way to do what I need, but I would like to have the variable @account"readily available". That is, without using this method, but making it available, for example, in my views, like this:
<%= debug @account %>