Issue
When using custom authentication via Rails 8 new Authentication generator, opening .../jobs, which should require a logged-in user or redirect to login page, results in a UrlGenerationError:
ActionController::UrlGenerationError in MissionControl::Jobs::QueuesController#index
No route matches {action: "new", controller: "sessions", server_id: nil}
def request_authentication
session[:return_to_after_authenticating] = request.url
redirect_to new_session_path
end
This would make any kind of custom authentication with redirects difficult and should not only effect the Rails 8 Auth generator.
To replicate
- init new Rails 8 project
- add gem "mission_control-jobs" and mount to "/jobs" according to Readme
- run
bin/rails generate authentication (which includes Authentication for all controllers)
- run
bin/dev
- go to http://127.0.0.1:3000/jobs
- -> UrlGenerationError
Quick Fix
Adding include Rails.application.routes.url_helpers to the MissionControl::Jobs::QueuesController solves the problem, but does not feel like a proper fix.
Weirdly, adding the url_helpers to the MissionControl::Jobs::ApplicationController does not help.
--
Any help or suggestions appreciated.
Issue
When using custom authentication via Rails 8 new Authentication generator, opening
.../jobs, which should require a logged-in user or redirect to login page, results in a UrlGenerationError:This would make any kind of custom authentication with redirects difficult and should not only effect the Rails 8 Auth generator.
To replicate
bin/rails generate authentication(which includesAuthenticationfor all controllers)bin/devQuick Fix
Adding
include Rails.application.routes.url_helpersto theMissionControl::Jobs::QueuesControllersolves the problem, but does not feel like a proper fix.Weirdly, adding the url_helpers to the
MissionControl::Jobs::ApplicationControllerdoes not help.--
Any help or suggestions appreciated.