Agile Web Development Example Application Question

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
page
73 of the print version. The book’s online errata directed me here with
my
questions.

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:

app/controllers/store_controller.rb>

class StoreController < ApplicationController

def index
@products = Product.salable_items
end

end

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

snip

def self.salable_items
find(:all,
:conditions => “date_available <= now()”,
:order => “date_available desc”)
end

_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:inindex’
script/server:48

When I connect with the admin controller, I see the following in the
mysql
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,
Melissa

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
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Hi melissa,

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

1.8.4

regards,
Erwin

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.

Melissa

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
the
binary components are Universal Binaries? If not, I’m thinking that
this
would be good for RoR development
on Mac OS X. I’m guessing that one could simply take the information
from
the following page as a starting point:

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

Just a thought,

-Conrad