This project is archived and is in readonly mode.
scaffold doesn't work correctly with modules
Reported by mgomez | May 30th, 2008 @ 01:07 PM
If you do scaffold with modules, the routes for the links inside views are not correctly generated.
To prove it, follow these steps:
-
Write in the console:
script/generate scaffold module/klass name:string
-
In your database:
CREATE TABLE klasses ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255));INSERT INTO "klasses" ("name") VALUES ("foo");
- Go to http://localhost:3000/module/kla...
-
You get the following error:
undefined method `module_klasses_path' for ActionView::Base:0xb698da1c
-
Check the source in config/routes.rb . Change
map.resources :klasses
formap.resources :module_klasses
-
Refresh your browser. You get the following error:
undefined local variable or method `klasses_path' for ActionView::Base:0xb6a4e5dc
-
Check the source in app/views/module/klasses/new.html.erb . Change
<%= link_to 'Back', klasses_path %>
for<%= link_to 'Back', module_klasses_path %>
- Refresh your browser. Now it shows correctly.
The process after step 6 can be also repeated for the other views (edit, show, index), and corrected similarly.
Comments and changes to this ticket
-
mgomez May 30th, 2008 @ 12:53 PM
Sorry, there is no preview in the ticketing system, I didn't mind to mess it up :-S
If you do scaffold with modules, the routes for the links inside views are not correctly generated.
Steps:
-
Write in the console:
script/generate scaffold -s module/klass name:string
-
In your database:
CREATE TABLE klasses ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
INSERT INTO "klasses" ("name") VALUES ("foo")
- Go to http://localhost:3000/module/kla...
-
You get the following error:
undefined method `module_klasses_path' for #
-
Check the source in config/routes.rb . Change
map.resources :klasses
formap.resources :module_klasses
-
Refresh your browser. You get the following error:
undefined local variable or method `klasses_path' for #
-
Check the source in app/views/module/klasses/new.html.erb . Change
<%= link_to 'Back', klasses_path %>
for<%= link_to 'Back', module_klasses_path %>
- Refresh your browser. It shows correctly.
The process after step 7 can be repeated for the other views: edit, show, index, and corrected similarly.
-
Write in the console:
-
mgomez May 30th, 2008 @ 01:05 PM
Never mind, I didn't realize of the "Edit ticket" link on top of the page. Could any admin delete both comments?
-
Jorge Bernal May 30th, 2008 @ 06:54 PM
Here is a patch that seems to fix this. However, the resource generator suffers the same issue
-
Pratik July 2nd, 2008 @ 02:00 AM
- State changed from new to wontfix
- Tag set to generators, patch, railties, routing
I get "Mysql::Error: Table 'project.users' doesn't exist: SELECT * FROM `users`" error when I tried "script/generate scaffold Admin::User"
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>