Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > BOOK: Beginning Ruby on Rails
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Ruby on Rails
This is the forum to discuss the Wrox book Beginning Ruby on Rails by Steve Holzner Ph.D.; ISBN: 9780470069158
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Ruby on Rails section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 16th, 2008, 02:50 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 5
Thanks: 0
Thanked 3 Times in 2 Posts
Default Chapter 6 - scaffold error, wrong number of args

When I run the scaffold command on p.167:

ruby script/generate scaffold Item Manage

I get the following:

      exists app/models/
      exists app/controllers/
      exists app/helpers/
      create app/views/items
      exists app/views/layouts/
      exists test/functional/
      exists test/unit/
      create app/views/items/index.html.erb
wrong number of arguments (1 for 2)

Running on OS X Leopard, with Rails 2.0.2. Any ideas?

Reply With Quote
  #2 (permalink)  
Old April 21st, 2008, 02:04 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In Rail 2.0.2,scaffold used like this:
   ruby script/generate scaffold Item field1:type1 field2:type2 ...
controller is named "items" automatically



Reply With Quote
  #3 (permalink)  
Old June 16th, 2008, 04:06 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, I don't quite understand what you're saying we should change the line to. What are the field:type entries used for?

I'm stuck at the same place that davidtspf is, getting the same error. What should I use for the scaffold line to generate an Item model and a Manage controller?

Did anyone get this working? Thanks!



Reply With Quote
  #4 (permalink)  
Old June 16th, 2008, 10:50 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I used the following to create the controller and the model:

$ ruby script/generate scaffold Item

which seems to work. I have the problem now of not knowing what to use in the browser URL. Typing the following in the browser

http://localhost:3000/items

gives me an error:
 ActiveRecord::StatementInvalid in ItemsController#index
 SQLite3::SQLException: no such table: items: SELECT * FROM items

I'm stuck again.




Reply With Quote
  #5 (permalink)  
Old June 16th, 2008, 02:41 PM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Found this, which may help.

http://fairleads.blogspot.com/2007/1...p-by-step.html

Go down a bit, to where there is a section header called "Old vs. New". The author there deals with the differences with how such a line should be set up.

It's much like what bimawen said. In order for the scaffold to have the title Manage, something like title:Manage must be used.

So I tried "ruby scrip/generate scaffold Item title:Manage", and it looks to be working so far. See if that will help

Reply With Quote
  #6 (permalink)  
Old June 18th, 2008, 01:21 PM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, scratch that. It looks like it will need to be "title:string". After that, it's still a mystery to me. Sorry.

Reply With Quote
  #7 (permalink)  
Old June 19th, 2008, 12:22 PM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, finally made it work by getting an older version of rails. Actually an older version of InstantRails is what I'm using, but at least the book example has worked up to where the /manage page has come up.

If you want to know, I'm using InstantRails 1.7.

Reply With Quote
  #8 (permalink)  
Old June 19th, 2008, 03:24 PM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's an update. I am using Rails 2.02, with Linux, which has enough changes to make it significantly different than the book.

As mentioned previously,
   I used the following to create the controller and the model:
     $ ruby script/generate scaffold Item
   which Rails accepted.

I was blocked and made changes to database.yml for mysql, since is defaulted to sqlite3. I then added the partial statement recommended in the book to /view/items/new.html.erb and created the _form.rhtml in views/items.

Next I made the changes suggested for list.rhtml to index.html.erb and now I can add/delete/list store items. I can see these changes in mysql.

I just need to get edit and show working.

This is painful.

Reply With Quote
  #9 (permalink)  
Old July 31st, 2008, 12:12 PM
Registered User
 
Join Date: Jul 2008
Location: Tucson, AZ, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Using Rails 2.1 on WinXP
Typed the following
ruby script/generate scaffold Item name:varchar(80) description:text price:decimal(8,2)

It seems to work so far after adding one item. URL has items where book lists manage (http://localhost:3000/items).


Reply With Quote
  #10 (permalink)  
Old October 17th, 2008, 02:05 AM
Registered User
 
Join Date: Oct 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

To get the store (chpt. 6) up and running with Rails 2.x, you need to do the following:

Don't create the sql databases as instructed, instead change to your rubydev directoy (or wherever you are storing your rails projects) and type:
Code:
rails store
change to the store directory (eg with cd store)

type:
Code:
ruby script/generate scaffold Item name:string description:text price:float
Then edit the config/database.yml file, adding your sql password where appropriate.

Then back to the console and type:
Code:
rake db:create:all
rake db:migrate
That's it.
You have created a model called "Item", a database table in store_development called "items" and a controller called "ItemController"

You can add records to the database under the url:
http://localhost:3000/items

The rest should be straight forward.
Hope this helps somebody.

P.S. Running Rails 2.x, MySQL version 5.x and Ubuntu Linux
Reply With Quote
The Following User Says Thank You to Jim_in_Germany For This Useful Post:
ryanm (August 13th, 2010)
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 6: scaffold syntax error cwhite124 BOOK: Beginning Ruby on Rails 1 January 3rd, 2008 06:20 AM
Can someone see what i did wrong here chapter 6 amo BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 April 8th, 2004 01:12 PM
Is Chapter 13 Code wrong??? miggitty VB.NET 2002/2003 Basics 0 December 30th, 2003 11:20 PM



All times are GMT -4. The time now is 02:53 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.