This project is archived and is in readonly mode.

#283 ✓wontfix
mgomez

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:

  1. Write in the console:script/generate scaffold module/klass name:string
  2. In your database:CREATE TABLE klasses ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255));INSERT INTO "klasses" ("name") VALUES ("foo");
  3. Go to http://localhost:3000/module/kla...
  4. You get the following error: undefined method `module_klasses_path' for ActionView::Base:0xb698da1c
  5. Check the source in config/routes.rb . Change map.resources :klasses for map.resources :module_klasses
  6. Refresh your browser. You get the following error: undefined local variable or method `klasses_path' for ActionView::Base:0xb6a4e5dc
  7. Check the source in app/views/module/klasses/new.html.erb . Change <%= link_to 'Back', klasses_path %> for <%= link_to 'Back', module_klasses_path %>
  8. 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

    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:

    1. Write in the console:script/generate scaffold -s module/klass name:string
    2. In your database: CREATE TABLE klasses ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))

    INSERT INTO "klasses" ("name") VALUES ("foo")

    1. Go to http://localhost:3000/module/kla...
    2. You get the following error:undefined method `module_klasses_path' for #
    3. Check the source in config/routes.rb . Change map.resources :klasses for map.resources :module_klasses
    4. Refresh your browser. You get the following error: undefined local variable or method `klasses_path' for #
    5. Check the source in app/views/module/klasses/new.html.erb . Change <%= link_to 'Back', klasses_path %> for <%= link_to 'Back', module_klasses_path %>
    6. Refresh your browser. It shows correctly.

    The process after step 7 can be repeated for the other views: edit, show, index, and corrected similarly.

  • mgomez

    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

    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

    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>

People watching this ticket

Attachments

Pages