small medium large xlarge

20 Jul 2010, 04:54
Robert F. (3 posts)

I’m in section 9.3, “Adding a Button,” and I’m finding that when I run the command “rake test:functionals” as described on p. 121 of the PDF, I get the following error:

…ruby-1.9.2-head@rls3b4/gems/activerecord-3.0.0.beta4/lib/active_record/relation.rb:220:in `destroy’: wrong number of arguments (0 for 1) (ArgumentError)

I thought that perhaps I typed something in wrong so I rolled back my code to the previous iteration, “Connecting Products to Carts,” in section 9.2 but even then, I still get the error. Is anyone else having this problem?

I’m running ruby 1.9.2dev (2010-06-27 revision 28447) [x86_64-darwin10.4.0] Rails 3.0.0.beta4


22 Jul 2010, 04:08
Robert F. (3 posts)

This example falls apart with Iteration D3. First of all, although this code is in iteration”D,” the code you can download from the site doesn’t show the changes introduced in this iteration until “depot_f,” not “depot_e” as you would expect. And then even if you try to run this downloaded code from depot_f, the “rake test:functionals” command still fails. It also doesn’t reflect the changes to line_items_controller_test.rb which is another inconsistency.

22 Jul 2010, 12:01
Sam Ruby (633 posts)

You are correct, the snapshot names aren’t aligned with iteration names. In a number of iterations, multiple snapshots are required.

All of the code in the book has been tested continuously against multiple releases of Ruby and the every build of Rails. For example: edition 4, Ruby 1.9.2, Rails version 3.0.0.beta4 plus changes through Wed Jul 21 08:13:31 2010 +0800. Click on 9.3 and you will see the changes you should make and the results you should see. At the bottom of the page you will see pub depot_f, which triggers the snapshot. Advance to 9.4 and you will see that rake test:rails does indeed fail at this point, but you also see the changes which are required to get the tests to work, and then see the tests actually passing.

Note: those pages are live. By the time you visit them, it might be a newer version of Rails, perhaps one with a bug in it that causes everything to fail.

But back to your original question: wrong number of arguments for destroy is not the expected result; something is different between what you have done and what I have done, and unfortunately I don’t have enough information at the moment to speculate as to what that might be.

Perhaps if you could show more of the stack trace I can make more of an educated guess.

23 Jul 2010, 05:21
Robert F. (3 posts)


Thanks for your response. I’ve been managing my code with Git and I’ve rolled back to how it was at the end of chapter 8. My thinking is that maybe I typed something in wrong somewhere. So now I’ve just entered the code for section 9.1 but when I run “rake test”, I get the message:

You have 1 pending migrations: 201…. CreateCarts Run “rake db:migrate” to update your database then try again.

However, if I do run the rake db:migrate command, I get the message,

SQLite3::SQLException: table “carts” already exists: CREATE TABLE…

I’m not sure how to delete this table. I’m guessing it’s in the binary file db/development.sqlite3 and I’d be afraid to delete it anyway as I don’t want to mess anything else up. Since I’m a “ruby noob,” I might just be better off going back and working through the previous edition of this book and reading this edition when it’s out of beta.

Thanks again for your previous response.


23 Jul 2010, 14:20
Sam Ruby (633 posts)

At this point, you have put nothing into the database that you can’t readily recreate. Deleting the database and running rake db:setup will restore the database.

Nothing you have said to this point indicates that the problem you are seeing is specific to Rails 3.0 or Edition 4. Nor have others that are using this beta reported this problem.

Be aware that if you go back to the previous edition you will also need to go back to Rails 2.3.x.

24 Jul 2010, 14:31
Bharat Ruparel (148 posts)

Hello Robert, You may want to hang in there with Rails 3 which is fairly close to release candidate. Reading through your thread, it seems like you are having trouble interacting with the SQKLite 3 database. There is a really nice Firefox plugin (you do use Firefox right?) called SQLite Manager that will be a big help if that is the problem. Simply go to the Tools menu select Add Ons and click on Get Add ons and search for SQLite Manager, install it and you are good to go. You may want to read through the plugin documentation to see how to use it, but it is rather straightfoward.

Once you can see what the rake db commands are doing to your database, you will gain a much better understanding and confidence.

Hope this helps.


18 Dec 2010, 12:07
Ben Kolera (1 post)


You probably don’t care anymore but I had the same error. The problem was mind numbingly simple but it took me a while to spot. I’d suggest that if you and I did the same thing then there may be others in the same boat who will find this information useful.

In app/models/cart.rb I had:

class Cart < ActiveRecord::Base 
  has_many :line_items, :dependent => destroy

Instead of this:

class Cart < ActiveRecord::Base 
  has_many :line_items, :dependent => :destroy

/facepalm :)


30 Dec 2010, 16:06
Michael Wiles (1 post)

Thanks Ben - I did the same thing. This ruby takes some getting used to.


You must be logged in to comment