2

I have this setup for Devise

devise_for :users, :controllers => {
  :confirmations => "confirmations", 
  :registrations => "registrations"} do
     put "confirm_user", :to => "confirmations#confirm_user" 
  end

and when I run

rake route 

I have get strange routes for registrations_controller specialy the edit_path

 edit_user_registration GET    /users/edit(.:format)             registrations#edit
                        PUT    /users(.:format)                  registrations#update
                        DELETE /users(.:format)                  registrations#destroy

The problem is edit url for example for first user.

I expected

/users/1/edit

but I have get

/users/edit.1

I expect this route can not work but it does. Now I am not sure if I have made some mistake or if the devise generate the routes this way.

And if it generate routes that way where goes the format of request?

I can not believe that the URL might look like this.

/users/edit.1.js

Thanks for any advise?

Suborx
  • 3,647
  • 2
  • 19
  • 30

3 Answers3

3

The issue is not related to the edit url, instead it depends on the page that is linking to the edit one. You have probably a link of this form

link_to "Settings", edit_user_registration_path(@user)

that point to the edit url, which generates the unexpected url

/users/edit.id

You simply have to replace the link omitting the @user, as

link_to "Settings", edit_user_registration_path
r4m
  • 491
  • 4
  • 14
  • this is the correct answer since I would only allow modification of the settings of the user only if they are logged in. – cevaris Jan 09 '14 at 18:19
1

That . is always there when showing a format. It's nothing from Devise, and there's nothing wrong with it. You're all good!

MrDanA
  • 11,489
  • 2
  • 36
  • 47
  • As you wrote the dot should separate the format of request but no the id of record that I want to edit. – Suborx May 02 '12 at 18:39
0

I am passing the id to the edit route but it doesn't expect an id.

The edit_user_registration_path is only for current_user so the user.id is unnecessary.

This question might be also helpful.

Devise: Allow admins to edit other users - Rails

Community
  • 1
  • 1
Suborx
  • 3,647
  • 2
  • 19
  • 30