ruby on rails - Manual routes and "Couldn't find User with id=new" error -
i'm trying create routes manually users model ( not "resource: users"),
so in routes.rb :
get '/users/:id', to: 'users#show', as: 'user' '/users/new', to: 'users#new', as: 'new_user' but when i'm trying go /users/new "couldn't find user id=new".
i understand why happens, want find way allow (without changing 1 of paths). how possible?
the order of routes important. because you've defined show route before new route, show action getting executed id new.
swap position of 2 routes:
get '/users/new', to: 'users#new', as: 'new_user' '/users/:id', to: 'users#show', as: 'user'
Comments
Post a Comment