'devise_for users not working with scope '(:locale)'

I have an issue when trying to access <%= link_to 'Profil', edit_user_registration_path(current_user), class: 'nav-text'%>

i get this error: No route matches [GET] "/1/users/edit"

note: this is the first time im using locale on a website and im sure the problem is linked to it, because on all other website i created usually the url is /users.edit.1

application_controller.rb

def default_url_options { locale: I18n.locale } end

def set_locale I18n.locale = extract_locale || I18n.default_locale end

def extract_locale parsed_locale = params[:locale] I18n.available_locales.map(&:to_s).include?(parsed_locale) ? parsed_locale : nil end

routes.rb

scope '(:locale)', locale: /#{I18n.available_locales.join("|")}/ do devise_for :users root to: 'dashboards#dashboard' get 'home', to: 'pages#home'

it do work when i use <%= link_to 'Mon espace perso', user_registration_path, class: 'nav-text', method: :put %>

it goes to the page when clicking on the link but the url on the browser doesn't change

and when i refresh the page while on edit user page, it goes to root path

any help or suggestion would be well appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source