Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

scaffold doesn't work correctly with modules

#283

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.

Reported by mgomez · May 30th, 2008 @ 01:07 PM

State: wontfix
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. mgomez
    mgomez

    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.

    May 30th, 2008 @ 12:53 PM

  2. mgomez
    mgomez

    Never mind, I didn't realize of the "Edit ticket" link on top of the page. Could any admin delete both comments?

    May 30th, 2008 @ 01:05 PM

  3. Jorge Bernal
    Jorge Bernal

    Here is a patch that seems to fix this. However, the resource generator suffers the same issue

    May 30th, 2008 @ 06:54 PM

  4. Pratik
    Pratik
    • 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"

    July 2nd, 2008 @ 02:00 AM