Melissa Anderson
2006-Feb-28 05:35 UTC
[Rails] 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 Development 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 Quita
2006-Feb-28 05:45 UTC
[Rails] Agile Web Development Example Application Question
Melissa Anderson wrote:> I''m new to Ruby and to fairly new to programming. I''ve been working > through the "Agile Web Development 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 > > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > 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
2006-Feb-28 06:01 UTC
[Rails] Agile Web Development Example Application Question
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, > > Ruby 1.8.3 is buggy. you should use 1.8.2 or the latest stable is > 1.8.4 > > regards, > Erwin > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Conrad Taylor
2006-Feb-28 07:22 UTC
[Rails] Agile Web Development Example Application Question
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_rails_lighttpd_mysql_tiger 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 On 2/27/06, Melissa Anderson <melissa@defazio.digithink.com> wrote:> > 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, > > > > Ruby 1.8.3 is buggy. you should use 1.8.2 or the latest stable is > > 1.8.4 > > > > regards, > > Erwin > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060228/cf9d098f/attachment.html