Forum: Ruby on Rails Agile Web Development Example Application Question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Melissa Anderson (Guest)
on 2006-02-28 07:36
(Received via mailing list)
I'm new to Ruby and to fairly new to programming. I've been working
through the "Agile Web D. with Rails" book, and I'm stuck on
73 of the print version. The book's online errata directed me here with

I'm running Ruby 1.8.3 with MySQL 4.1.8 on OSX 10.3.9. I've created the
scaffolding for Admin controller and entered three sample products. I
typed the examples to build the Store controller carefully and finally
just copied them from what the book's Web site supplies. So now I have:


class StoreController < ApplicationController

  def index
    @products = Product.salable_items


and in the app/models/product.rb I have the new piece of code


  def self.salable_items
         :conditions => "date_available <= now()",
         :order      => "date_available desc")

_____end snip____

When I try to access the store page, it returns:

Couldn't find Product with ID=all AND date_available <= now()

/app/models/product.rb:21:in `salable_items'
app/controllers/store_controller.rb:4:in `index'

When I connect with the admin controller, I see the following in the
connection logs that I set up:

060227 21:22:09       2 Connect     root@localhost on depot_development
                      2 Query       SELECT * FROM products
                      2 Query       SHOW FIELDS FROM products

When I connect with the store controller, I see:

060227 21:23:02       3 Connect     root@localhost on depot_development
                      3 Query       SELECT * FROM products WHERE id =
:all' AND date_available <= now()  LIMIT 1

So it is connecting to the database, but id = '--- :all' isn't a
meaningful id number. Thing is, I don't really understand how or why the
find() function and :all produces that . . .

Any help would be greatly appreciated!

Thanks in advance,
Erwin Q. (Guest)
on 2006-02-28 07:47
(Received via mailing list)
Melissa Anderson wrote:
> app/controllers/store_controller.rb>
> and in the app/models/product.rb I have the new piece of code
> _____end snip____
> connection logs that I set up:
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
Hi melissa,

    Ruby 1.8.3 is buggy. you should use 1.8.2 or the latest stable is

Melissa Anderson (Guest)
on 2006-02-28 08:04
(Received via mailing list)
I get the same behavior with 1.8.2. I'll try 1.8.4 if I can find a
precompiled version that doesn't need the developer's tools.

Thanks for the quick response.

Conrad T. (Guest)
on 2006-02-28 09:24
(Received via mailing list)
Hi Melissa, thanks for saying something about the precompiled libraries
because I have the following questions for the group:

Are there plans to create an installer (i.e. .dmg ) for Mac OS X where
binary components are Universal Binaries?  If not, I'm thinking that
would be good for RoR development
on Mac OS X.  I'm guessing that one could simply take the information
the following page as a starting point:

I guess that I would simply have to go down the list creating packages
each one of the
steps in this process.  Then incorporate those packages into the .dmg
Finally, I'm guessing a software update component would be nice but not

Just a thought,

This topic is locked and can not be replied to.