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.

generate scaffold problems with namespace

#1157

ruby ./script/generate scaffold admin/book name:string

routes not namespaced

map.resources :books

# should be

map.namespace :admin do |admin|

admin.resources :books

end

model uses wrong table name

# needed to add

set_table_name "admin_books"

controller variables not consistant with the views

controller/index = @admin_books # good

view/index = @books # should be @admin_books

controller/show, new, edit, create, update, delete = @book # should be @admin_book

view/show, new, edit = @book # should be @admin_book

all the link_to's were books_path # should be admin_books_path

the forms do not save the data (name) to the database

params[:book] # should be params[:admin_book]

the tests are also a mess

i haven't looked into the other generators yet

Reported by scottnj · October 2nd, 2008 @ 04:45 PM

State: duplicate
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Arjun
    Arjun
    • Tag changed from 2.1.1, generate, namespace, scaffold to 2.1.1, generate, namespace, scaffold

    I also got the same error. Someone going to correct this?

    October 17th, 2008 @ 03:50 PM

  2. CamasMan
    CamasMan

    If you ask me, scaffolding should allow me to setup a system for the model, Book, and then append a system using a controller and views in the admin namespace - but reference the normal Book model. That allows me to customize the "normal" set of controller/helper/views to set the user experience, and then to customize the /admin/book controller/helper/views differently to set a unique admin experience.

    Referencing the @admin_book object from the Admin::Book model isn't typically what's needed in the admin space.

    November 3rd, 2008 @ 07:56 AM

  3. Danilo
    Danilo

    Hi, i've generated static scaffold on my test machine with script/generate scaffold Admin::Users .

    The only problem that I've is table name in model class, users istead of admin_users (as defined by script in migration file).

    By design what's the rigth way? In the mean time I've to force table name in model class ?

    Thanks Danilo

    November 4th, 2008 @ 02:34 PM

  4. tsechingho
    tsechingho
    • Tag changed from 2.1.1, generate, namespace, scaffold to 2.2, generate, namespace, scaffold

    How about the namespace other than "admin"?

    Loading development environment (Rails 2.2.0)

    Product::Variant.table_name => "product_variants" Shipping::Category.table_name => "categories"

    Product::Variant is created under rails 2.1.1 and Shipping::Category is created under rails 2.2.0(edge). Both of them are in the same project but I have to set table name manually for Shipping::Category.

    November 4th, 2008 @ 05:25 PM

  5. Danilo
    Danilo

    My problem is with Rails 2.1.1

    November 4th, 2008 @ 05:31 PM

  6. Danilo
    Danilo

    Mmm ... I've discovered that also form_for fail.

    I've this situation: Namespace Admin - Class Admin::User

       |->Has Many -> Class Admin::Trip
    
    

    In Trip template form_for looks for admin_trip_path instead of admin_user_trip_path.

    I don't know rails so good so I don't understand if it's a bug or not.

    November 6th, 2008 @ 01:53 PM

  7. Pratik
  8. CancelProfileIsBroken