Hi everbody, I'm new in the forum. I' studing ruby and rails and I hope learn faster with the help of the forum. Well, my problem is basic. I have made a scaffold to create a new object User. User has name, email and password. I created a new view named "login", but i don't know how to make the route to this view. I Have the function in the controller too. Cbapp::Application.routes.draw do resources :users root :to => 'users#index' match 'users/login' => 'users#login' end and I got this error: Couldn't find User with id=login Thanks!
on 2012-10-31 15:22
on 2012-10-31 15:40
Try this: > Cbapp::Application.routes.draw do > root :to => 'users#index' > match 'users/login' => 'users#login' > resources :users > end Enviado desde mi iPhone El 31/10/2012, a las 15:22, IT Coobo Internal Team <lists@ruby-forum.com> escribi:
on 2012-10-31 16:04
On 31 October 2012 14:22, IT Coobo Internal Team <lists@ruby-forum.com> wrote: > Hi everbody, > > I'm new in the forum. I' studing ruby and rails and I hope learn faster > with the help of the forum. I suggest your best plan might be to work right through a tutorial on rails to help you to understand the basics. railstutorial.org is good and is free to use online. Make sure that any tutorial you use is for Rails 3 and that you use exactly the right version of rails that the tutorial expects. Colin
on 2012-10-31 16:07
WOW! I don't believe it. I only have to reorder the lines as hazardco said! SOLVED! but i have a question. Why reorder the lines solved my problem? anyway thanks guy.
on 2012-10-31 16:12
Il 31/10/12 15:22, IT Coobo Internal Team ha scritto: > Cbapp::Application.routes.draw do > resources :users > root :to => 'users#index' > match 'users/login' => 'users#login' > end rules order in routes.rb is important: users resource 'users/:id' matches before 'users/login' so login is the id :) you can invert the order of the rules or, better, use a member: Cbapp::Application.routes.draw do resources :users do member do get 'login' end end root :to => 'users#index' end Take a look here: http://guides.rubyonrails.org/routing.html#adding-...
on 2012-10-31 16:14
Sorry, use a collection, not a member:
Cbapp::Application.routes.draw do
resources :users do
collection do
get 'login'
end
end
root :to => 'users#index'
end
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.