I know this is a minor issue, but why, if you use scaffolding in RoR, can you use lines like 'new_*model name here*_path' in link tags, but without using scaffolding, I get a NameError? For example, I have a simple address book app that uses basic CRUD operations. I am a RoR beginner but wanted to build an app without scaffolding and these kind of things don't seem to work. I compared my config/routes.rb and app/helpers/* with those in a scaffolded app and they are no different. What am I missing?
+4
A:
Scaffolding sets up resource routes in the routes.rb file. The resource routes are what give you the path and url helpers. When you don't use scaffolding the routes aren't added, you must do it by hand.
Resource Routes can be added like so:
map.resources :models
where :models is the plural name of one of your models.
Jason Punyon
2009-05-11 10:30:08
I have that...like I said in the question, my config/routes.rb and all the *_helper.rb files in my app are the same as the ones in a scaffolded app (except for the model names of course)
W_P
2009-05-11 10:41:44
Never mind, my resource was singular in my routes...thanks!
W_P
2009-05-11 10:44:09
@Paul: It always comes down to some stupid detail...:)
Jason Punyon
2009-05-11 10:49:42
yea it sure does...
W_P
2009-05-11 10:57:05
+3
A:
One way to check your routes and paths is to run:
rake routes
It outputs all your routes and paths.
srboisvert
2009-05-11 14:07:58