Setting Devise Login to be root page

To follow on from the people who are asking about the error Could not find devise mapping for path "https://stackoverflow.com/" there is a workaround.

You’ll find that there is a clue in your logs which will probably say:

[Devise] Could not find devise mapping for path "https://stackoverflow.com/".
This may happen for two reasons:

1) You forgot to wrap your route inside the scope block. For example:

  devise_scope :user do
    match "/some/route" => "some_devise_controller"
  end

2) You are testing a Devise controller bypassing the router.
   If so, you can explicitly tell Devise which mapping to use:

   @request.env["devise.mapping"] = Devise.mappings[:user]

So I retried the approach but instead wrapping it (as @miccet suggets) inside a scope block:

devise_scope :user do
  root to: "devise/sessions#new"
end

This worked fine for me

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)