Module: Rodauth::Rails::ControllerMethods
- Defined in:
- lib/rodauth/rails/controller_methods.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(controller) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/rodauth/rails/controller_methods.rb', line 4 def self.included(controller) # ActionController::API doesn't have helper methods if controller.respond_to?(:helper_method) controller.helper_method :rodauth, :current_account end end |
Instance Method Details
#current_account(name = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rodauth/rails/controller_methods.rb', line 15 def current_account(name = nil) model = rodauth(name).rails_account_model id = rodauth(name).session_value @current_account ||= {} @current_account[name] ||= fetch_account(model, id) do rodauth(name).clear_session rodauth(name).login_required end end |
#rodauth(name = nil) ⇒ Object
11 12 13 |
# File 'lib/rodauth/rails/controller_methods.rb', line 11 def rodauth(name = nil) request.env.fetch ["rodauth", *name].join(".") end |