This project is archived and is in readonly mode.

#1157 ✓duplicate

generate scaffold problems with namespace

Reported by scottnj | October 2nd, 2008 @ 04:45 PM | in 2.x

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

routes not namespaced

map.resources :books

# should be

map.namespace :admin do |admin|

admin.resources :books


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

Comments and changes to this ticket

  • Arjun

    Arjun October 17th, 2008 @ 03:50 PM

    • 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?

  • CamasMan

    CamasMan November 3rd, 2008 @ 07:56 AM

    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.

  • Danilo

    Danilo November 4th, 2008 @ 02:34 PM

    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

  • tsechingho

    tsechingho November 4th, 2008 @ 05:25 PM

    • 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.

  • Danilo

    Danilo November 4th, 2008 @ 05:31 PM

    My problem is with Rails 2.1.1

  • Danilo

    Danilo November 6th, 2008 @ 01:53 PM

    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.

  • Pratik

    Pratik March 12th, 2009 @ 05:03 PM

    • State changed from “new” to “duplicate”
  • CancelProfileIsBroken

    CancelProfileIsBroken March 12th, 2009 @ 05:20 PM

    Other ticket, with potential patch: #1976

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=""></a>

Referenced by