0

ok, i have users, and i want to have the options to edit their names. my route looks like this

namespace :admin do
    resources :users
end

my index:

   - @users.each do |user|
   %tr
      %td= link_to user.last_name, admin_user_path(user)
      %td= user.first_name
      %td= link_to "Edit", edit_admin_user_path(user), class: "btn"

= paginate @users

controller

class Admin::UsersController < AdminController
    def edit
        @user = User.find(params[:id])
    end

and the form:

= simple_form_for @user do |f|
  %p New first name
  = f.input :first_name
  %p New last name
  = f.input :last_name
  = f.button :submit

When i press the 'edit' button on the index page, it gives me 'undefined method `user_path'' error, pointing into first line of the form. i tried to solve it poorly with adding resources :users and it allowed me to render form, but when i try to save it, it gives me uninitialized 'constant UsersController'. What is going on with this user_path since i'm not using it anywhere? how can i solve this problem, best would be without any extra routes...

1 Answer 1

2

change the form to

=simple_form_for [:admin, @user] do |f|

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.