Module: Rodauth::Rails::App::RequestMethods
- Defined in:
- lib/rodauth/rails/app.rb
Instance Method Summary collapse
-
#POST ⇒ Object
The Rack input might not be rewindable, so ensure we parse the JSON request body in Rails, and avoid parsing it again in Roda.
-
#redirect ⇒ Object
When calling a Rodauth method that redirects inside the Rails router, Roda’s after hook that commits the flash would never get called, so we make sure to commit the flash beforehand.
-
#rodauth(name = nil) ⇒ Object
Automatically route the prefix if it hasn’t been routed already.
Instance Method Details
#POST ⇒ Object
The Rack input might not be rewindable, so ensure we parse the JSON request body in Rails, and avoid parsing it again in Roda.
88 89 90 91 92 93 |
# File 'lib/rodauth/rails/app.rb', line 88 def POST if content_type =~ /json/ env["roda.json_params"] = scope.rails_request.POST.to_hash end super end |
#redirect ⇒ Object
When calling a Rodauth method that redirects inside the Rails router, Roda’s after hook that commits the flash would never get called, so we make sure to commit the flash beforehand.
98 99 100 101 |
# File 'lib/rodauth/rails/app.rb', line 98 def redirect(*) scope.rails_request.commit_flash super end |
#rodauth(name = nil) ⇒ Object
Automatically route the prefix if it hasn’t been routed already. This way people only have to update prefix in their Rodauth configurations.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rodauth/rails/app.rb', line 73 def rodauth(name = nil) prefix = scope.rodauth(name).prefix if prefix.present? && remaining_path == path_info on prefix[1..-1] do super pass # forward other {prefix}/* requests downstream end else super end end |