Forum: Ruby on Rails Agile Web Development Example Application Question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community 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
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:in `index'
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
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
> 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
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.

Melissa
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
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:

http://hivelogic.com/articles/2005/12/01/ruby_rail...

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
This topic is locked and can not be replied to.