I am using Ruby on Rails 3 and I am trying to use middlewares in order to set a variable @variable_name
accessible later in controllers.
For example my middleware is
class Auth
def initialize(app)
@app = app
end
def call(env)
@account ||= Account.find(1)
@app.call(env)
end
end
The above code set properly the @account
variable, but that isn't available in my application (in controllers, models, views, ...). So, how can I accomplish that?
I seen this answer that is a way to do what I need, but I would like to have the @account
variable "directly accessible". That is, without use that way but making that available, for example in my views, like this:
<%= debug @account %>