Skip to content

UrlGenerationError for new_session_path (Custom authentication via Rails 8) #245

@stebo

Description

@stebo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions