Being completely new to Rails development, I try to understand the following: I am working with the Devise + Cancan + olify application to try to create authentication and user management. My normal user behavior is sorted, and I'm trying to get the admin user to be able to edit another user profile.
Currently, the admin user can list users and try to change another user profile. However, when you go to the edit page, even though the URL / route is correct for me, I am still provided with the information "currentuser" / admin in the form.
So, the scenario: UserId1 is the administrator. UserId1 is trying to change the profile of UserId2
Written as UserId1, the following route contains information for UserId1 instead of UserId2: http://localhost:3000/d/users/edit.2
Here is the .rb route:
devise_for :users, :path_prefix => 'd', :controllers => { :registrations => 'registrations' }
namespace :admin do
get '', to: 'dashboard#index', as: '/'
resources :users
end
Here is a list of # index users:
<table>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.id %></td>
<td><%= user.first_name %></td>
<td><%= user.last_name %></td>
<td><%= user.email %></td>
<td>
<%= link_to edit_user_registration_path(user) %>
</td>
<td>
<%= link_to registration_path(user),class: "red", :data => { :confirm => "Are you sure?" }, :method => :delete %>
</td>
</tr>
<% end %>
</tbody>
</table>
Here is user_controller.rb:
class Admin::UsersController < ApplicationController
def index
@users = User.all
end
end
Any help is appreciated!
Change 1
rake routes gives me the following:
Prefix Verb URI Pattern Controller
new_user_session GET /d/users/sign_in(.:format) devise/sessions
user_session POST /d/users/sign_in(.:format) devise/sessions
destroy_user_session DELETE /d/users/sign_out(.:format) devise/sessions
user_password POST /d/users/password(.:format) devise/passwords
new_user_password GET /d/users/password/new(.:format) devise/passwords
edit_user_password GET /d/users/password/edit(.:format) devise/passwords
PATCH /d/users/password(.:format) devise/passwords
PUT /d/users/password(.:format) devise/passwords
cancel_user_registration GET /d/users/cancel(.:format) registrations
user_registration POST /d/users(.:format) registrations
new_user_registration GET /d/users/sign_up(.:format) registrations
edit_user_registration GET /d/users/edit(.:format) registrations
PATCH /d/users(.:format) registrations
PUT /d/users(.:format) registrations
DELETE /d/users(.:format) registrations
user_confirmation POST /d/users/confirmation(.:format) devise/confirmations
new_user_confirmation GET /d/users/confirmation/new(.:format) devise/confirmations
GET /d/users/confirmation(.:format) devise/confirmations
user_unlock POST /d/users/unlock(.:format) devise/unlocks
new_user_unlock GET /d/users/unlock/new(.:format) devise/unlocks
GET /d/users/unlock(.:format) devise/unlocks
root GET / pages
about GET /about(.:format) pages
admin GET /admin(.:format) admin/dashboard
admin_users GET /admin/users(.:format) admin/users
POST /admin/users(.:format) admin/users
new_admin_user GET /admin/users/new(.:format) admin/users
edit_admin_user GET /admin/users/:id/edit(.:format) admin/users
admin_user GET /admin/users/:id(.:format) admin/users
PATCH /admin/users/:id(.:format) admin/users
PUT /admin/users/:id(.:format) admin/users
DELETE /admin/users/:id(.:format) admin/users