SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ruby script/generate scaffold Product Admin - doesn't create admin

    i'm going through chapter 6 of agile web development with rails (pdf) . i'm running the example on page 53, and instead of giving me views in the admin directory, it creates them in the products directory.

    so i can't access (as the book shows) the url using:
    http://localhost:3000/admin

    but i can get there (and create items) using:
    http://localhost:3000/products

    has anyone else experienced this?

    i'm using xp, with ruby 1.8.2

    (output from the command)
    C:\temp\ard\depot>ruby script/generate scaffold Product Admin
    exists app/controllers/
    exists app/helpers/
    create app/views/products
    exists test/functional/
    dependency model
    exists app/models/
    exists test/unit/
    exists test/fixtures/
    create app/models/product.rb
    create test/unit/product_test.rb
    create test/fixtures/products.yml
    create app/views/products/_form.rhtml
    create app/views/products/list.rhtml
    create app/views/products/show.rhtml
    create app/views/products/new.rhtml
    create app/views/products/edit.rhtml
    create app/controllers/products_controller.rb
    create test/functional/products_controller_test.rb
    create app/helpers/products_helper.rb
    create app/views/layouts/products.rhtml
    create public/stylesheets/scaffold.css

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Yakima WA.
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it seems that you entered the controller and model backwards for what you wanted to do. try this instead:

    script/generate scaffold Admin Product

    That should give you an admin controller for your product model.

  3. #3
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the suggestion, but that syntax gives an error:

    C:\temp\ard\depot>ruby script/generate scaffold Admin Product
    exists app/controllers/
    exists app/helpers/
    create app/views/admins
    exists test/functional/
    dependency model
    exists app/models/
    exists test/unit/
    exists test/fixtures/
    create app/models/admin.rb
    create test/unit/admin_test.rb
    create test/fixtures/admins.yml
    error Before updating scaffolding from new DB schema, try creating a tab
    le for your model (Admin)

  4. #4
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here is the text from the book:

    depot> ruby script/generate scaffold Product Admin
    dependency model
    exists app/models/
    exists test/unit/
    exists test/fixtures/
    create app/models/product.rb
    create test/unit/product_test.rb
    : :
    create app/views/admin/show.rhtml
    create app/views/admin/new.rhtml
    create app/views/admin/edit.rhtml
    create app/views/admin/_form.rhtml

    That wasn’t hard now, was it?

    That single command has written a basic maintenance application. The
    Product parameter told the command the name of the model we want, and
    the Admin parameter specifies the name of the controller.

  5. #5
    SitePoint Evangelist lirux's Avatar
    Join Date
    Jan 2001
    Location
    Lisboa : Portugal
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you already have a controller called admin before running this?
    It should work anyway, but are you running the latest rails (1.0)?

    By the way, you can get help for those commands by running them without arguments, i.e
    script/generate scaffold
    gives you the help for the scaffold generator, while
    script/generate
    shows help for generators in general.
    Duarte Carrilho da Graša
    RailsHelp.com: Searchable Rails reference
    CACA: Committee for the Annihilation of Complicated Acronyms


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •