Reputation: 2103
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...
Upvotes: 0
Views: 675