I was successful in reaching page 184 in the book "Agile Web Development with Rails" 3rd edition and while running the website with PostGreSQL as the backend, the power went down. The PostGreSQL database contents look OK and so do the source code files I was editing. But whenever I click on any "Add To Cart" button in the catalog, I get the following information in the terminal window where the "script/server" command was issued. By the way, I''m using Mongrel, not Webrick. Processing StoreController#add_to_cart (for 127.0.0.1 at 2009-04-06 11:49:15) [POST] Parameters: {"commit"=>"Add to Cart", "authenticity_token"=>"2hiFEqPkmMUXAZnTJ6jN4TKkMagLt0BY0W/M6fJj1+w=", "id"=>"1"} Product Load (1.0ms) SELECT * FROM "products" WHERE ("products"."id" = 1) NoMethodError (You have a nil object when you didn''t expect it! The error occurred while evaluating nil.add_product): app/controllers/store_controller.rb:9:in `add_to_cart'' /usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'' /usr/lib/ruby/1.8/mongrel.rb:158:in `each'' /usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'' /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' /usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'' /usr/lib/ruby/1.8/mongrel.rb:285:in `new'' /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' /usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'' /usr/lib/ruby/1.8/mongrel.rb:268:in `new'' /usr/lib/ruby/1.8/mongrel.rb:268:in `run'' Rendered rescues/_trace (72.4ms) Rendered rescues/_request_and_response (0.8ms) Rendering rescues/layout (internal_server_error) I really don''t want to lose all my work, but I''m totally lost on how to fix this problem. Sincerely, Arthur --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you cannot see why the object at line 9 in store_controller.rb is nil then now is your chance to learn about ruby-debug. Have a look and see what is happening. (I don''t know the answer). 2009/4/6 eengnerd <eengnerd-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>> > I was successful in reaching page 184 in the book "Agile Web > Development with Rails" 3rd edition and while running the website with > PostGreSQL as the backend, the power went down. The PostGreSQL > database contents look OK and so do the source code files I was > editing. But whenever I click on any "Add To Cart" button in the > catalog, I get the following information in the terminal window where > the "script/server" command was issued. By the way, I''m using > Mongrel, not Webrick. > > Processing StoreController#add_to_cart (for 127.0.0.1 at 2009-04-06 > 11:49:15) [POST] > Parameters: {"commit"=>"Add to Cart", > "authenticity_token"=>"2hiFEqPkmMUXAZnTJ6jN4TKkMagLt0BY0W/M6fJj1+w=", > "id"=>"1"} > Product Load (1.0ms) SELECT * FROM "products" WHERE > ("products"."id" = 1) > > NoMethodError (You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.add_product): > app/controllers/store_controller.rb:9:in `add_to_cart'' > /usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'' > /usr/lib/ruby/1.8/mongrel.rb:158:in `each'' > /usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'' > /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' > /usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'' > /usr/lib/ruby/1.8/mongrel.rb:285:in `new'' > /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' > /usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'' > /usr/lib/ruby/1.8/mongrel.rb:268:in `new'' > /usr/lib/ruby/1.8/mongrel.rb:268:in `run'' > > Rendered rescues/_trace (72.4ms) > Rendered rescues/_request_and_response (0.8ms) > Rendering rescues/layout (internal_server_error) > > I really don''t want to lose all my work, but I''m totally lost on how > to fix this problem. > > Sincerely, > > Arthur > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Nice idea, but I don''t have any books or tutorials on that...don''t even know how to start the debugger. Arthur On Apr 6, 12:16 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> If you cannot see why the object at line 9 in store_controller.rb is nil > then now is your chance to learn about ruby-debug. Have a look and see what > is happening. (I don''t know the answer). > > 2009/4/6 eengnerd <eengn...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > > > > > I was successful in reaching page 184 in the book "Agile Web > > Development with Rails" 3rd edition and while running the website with > > PostGreSQL as the backend, the power went down. The PostGreSQL > > database contents look OK and so do the source code files I was > > editing. But whenever I click on any "Add To Cart" button in the > > catalog, I get the following information in the terminal window where > > the "script/server" command was issued. By the way, I''m using > > Mongrel, not Webrick. > > > Processing StoreController#add_to_cart (for 127.0.0.1 at 2009-04-06 > > 11:49:15) [POST] > > Parameters: {"commit"=>"Add to Cart", > > "authenticity_token"=>"2hiFEqPkmMUXAZnTJ6jN4TKkMagLt0BY0W/M6fJj1+w=", > > "id"=>"1"} > > Product Load (1.0ms) SELECT * FROM "products" WHERE > > ("products"."id" = 1) > > > NoMethodError (You have a nil object when you didn''t expect it! > > The error occurred while evaluating nil.add_product): > > app/controllers/store_controller.rb:9:in `add_to_cart'' > > /usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'' > > /usr/lib/ruby/1.8/mongrel.rb:158:in `each'' > > /usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'' > > /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' > > /usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'' > > /usr/lib/ruby/1.8/mongrel.rb:285:in `new'' > > /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' > > /usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'' > > /usr/lib/ruby/1.8/mongrel.rb:268:in `new'' > > /usr/lib/ruby/1.8/mongrel.rb:268:in `run'' > > > Rendered rescues/_trace (72.4ms) > > Rendered rescues/_request_and_response (0.8ms) > > Rendering rescues/layout (internal_server_error) > > > I really don''t want to lose all my work, but I''m totally lost on how > > to fix this problem. > > > Sincerely, > > > Arthur--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
OK, got ruby-debug installed and issued the command: script/server -u Got running in debug mode. No more info than before. Now what? Arthur On Apr 6, 12:24 pm, eengnerd <eengn...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Nice idea, but I don''t have any books or tutorials on that...don''t > even know how to start the debugger. > > Arthur > > On Apr 6, 12:16 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > If you cannot see why the object at line 9 in store_controller.rb is nil > > then now is your chance to learn about ruby-debug. Have a look and see what > > is happening. (I don''t know the answer). > > > 2009/4/6 eengnerd <eengn...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > > > > I was successful in reaching page 184 in the book "Agile Web > > > Development with Rails" 3rd edition and while running the website with > > > PostGreSQL as the backend, the power went down. The PostGreSQL > > > database contents look OK and so do the source code files I was > > > editing. But whenever I click on any "Add To Cart" button in the > > > catalog, I get the following information in the terminal window where > > > the "script/server" command was issued. By the way, I''m using > > > Mongrel, not Webrick. > > > > Processing StoreController#add_to_cart (for 127.0.0.1 at 2009-04-06 > > > 11:49:15) [POST] > > > Parameters: {"commit"=>"Add to Cart", > > > "authenticity_token"=>"2hiFEqPkmMUXAZnTJ6jN4TKkMagLt0BY0W/M6fJj1+w=", > > > "id"=>"1"} > > > Product Load (1.0ms) SELECT * FROM "products" WHERE > > > ("products"."id" = 1) > > > > NoMethodError (You have a nil object when you didn''t expect it! > > > The error occurred while evaluating nil.add_product): > > > app/controllers/store_controller.rb:9:in `add_to_cart'' > > > /usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'' > > > /usr/lib/ruby/1.8/mongrel.rb:158:in `each'' > > > /usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'' > > > /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' > > > /usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'' > > > /usr/lib/ruby/1.8/mongrel.rb:285:in `new'' > > > /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' > > > /usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'' > > > /usr/lib/ruby/1.8/mongrel.rb:268:in `new'' > > > /usr/lib/ruby/1.8/mongrel.rb:268:in `run'' > > > > Rendered rescues/_trace (72.4ms) > > > Rendered rescues/_request_and_response (0.8ms) > > > Rendering rescues/layout (internal_server_error) > > > > I really don''t want to lose all my work, but I''m totally lost on how > > > to fix this problem. > > > > Sincerely, > > > > Arthur--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
There are lots of tutorials. Also look at the rails guides and railscasts. I can''t point to them off the top of my head but I am sure google will find them. 2009/4/6 eengnerd <eengnerd-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>> > OK, got ruby-debug installed and issued the command: script/server -u > Got running in debug mode. No more info than before. Now what? > > Arthur > > On Apr 6, 12:24 pm, eengnerd <eengn...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > Nice idea, but I don''t have any books or tutorials on that...don''t > > even know how to start the debugger. > > > > Arthur > > > > On Apr 6, 12:16 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > If you cannot see why the object at line 9 in store_controller.rb is > nil > > > then now is your chance to learn about ruby-debug. Have a look and see > what > > > is happening. (I don''t know the answer). > > > > > 2009/4/6 eengnerd <eengn...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > > > > > > I was successful in reaching page 184 in the book "Agile Web > > > > Development with Rails" 3rd edition and while running the website > with > > > > PostGreSQL as the backend, the power went down. The PostGreSQL > > > > database contents look OK and so do the source code files I was > > > > editing. But whenever I click on any "Add To Cart" button in the > > > > catalog, I get the following information in the terminal window where > > > > the "script/server" command was issued. By the way, I''m using > > > > Mongrel, not Webrick. > > > > > > Processing StoreController#add_to_cart (for 127.0.0.1 at 2009-04-06 > > > > 11:49:15) [POST] > > > > Parameters: {"commit"=>"Add to Cart", > > > > "authenticity_token"=>"2hiFEqPkmMUXAZnTJ6jN4TKkMagLt0BY0W/M6fJj1+w=", > > > > "id"=>"1"} > > > > Product Load (1.0ms) SELECT * FROM "products" WHERE > > > > ("products"."id" = 1) > > > > > > NoMethodError (You have a nil object when you didn''t expect it! > > > > The error occurred while evaluating nil.add_product): > > > > app/controllers/store_controller.rb:9:in `add_to_cart'' > > > > /usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'' > > > > /usr/lib/ruby/1.8/mongrel.rb:158:in `each'' > > > > /usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'' > > > > /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' > > > > /usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'' > > > > /usr/lib/ruby/1.8/mongrel.rb:285:in `new'' > > > > /usr/lib/ruby/1.8/mongrel.rb:285:in `run'' > > > > /usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'' > > > > /usr/lib/ruby/1.8/mongrel.rb:268:in `new'' > > > > /usr/lib/ruby/1.8/mongrel.rb:268:in `run'' > > > > > > Rendered rescues/_trace (72.4ms) > > > > Rendered rescues/_request_and_response (0.8ms) > > > > Rendering rescues/layout (internal_server_error) > > > > > > I really don''t want to lose all my work, but I''m totally lost on how > > > > to fix this problem. > > > > > > Sincerely, > > > > > > Arthur > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
eengnerd wrote:> Nice idea, but I don''t have any books or tutorials on that...don''t > even know how to start the debugger. > > ArthurA quick Web search on the subject would give you the answer. (FWIW, I was equally unenlightened about the debugger till about 2 days ago.) Best, -- Marnen Laibow-Koser marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org http://www.marnen.org -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Does this line produce a product? Product Load (1.0ms) SELECT * FROM "products" WHERE ("products"."id" = 1) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Obviously not in the estimation of the mongrel server and interacting code, but the database records are there and the id does exist. Arthur On Apr 6, 1:36 pm, Freddy Andersen <fre...-RCI/mp9mI1I6GGFevw1D/A@public.gmane.org> wrote:> Does this line produce a product? > > Product Load (1.0ms) SELECT * FROM "products" WHERE > ("products"."id" = 1)--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I tried dropping ALL the tables in the PostGreSQL database and running rake db:migrate again. This results in the very same error messages as before. As the system was running successfully before the power outage, I''m of the opinion that there is something else going on here...perhaps there''s a way to recompile all of the ruby source files? Arthur On Apr 6, 1:58 pm, eengnerd <eengn...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Obviously not in the estimation of the mongrel server and interacting > code, but the database records are there and the id does exist. > > Arthur > > On Apr 6, 1:36 pm, Freddy Andersen <fre...-RCI/mp9mI1I6GGFevw1D/A@public.gmane.org> wrote: > > > Does this line produce a product? > > > Product Load (1.0ms) SELECT * FROM "products" WHERE > > ("products"."id" = 1)--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You need to show your controller or view. I seriously doubt something went that wrong with ruby, but an apt-get should work just fine to re-install. -ht On Apr 6, 4:13 pm, eengnerd <eengn...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> I tried dropping ALL the tables in the PostGreSQL database and running > rake db:migrate again. This results in the very same error messages > as before. As the system was running successfully before the power > outage, I''m of the opinion that there is something else going on > here...perhaps there''s a way to recompile all of the ruby source > files? > > Arthur > > On Apr 6, 1:58 pm, eengnerd <eengn...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > Obviously not in the estimation of the mongrel server and interacting > > code, but the database records are there and the id does exist. > > > Arthur > > > On Apr 6, 1:36 pm, Freddy Andersen <fre...-RCI/mp9mI1I6GGFevw1D/A@public.gmane.org> wrote: > > > > Does this line produce a product? > > > > Product Load (1.0ms) SELECT * FROM "products" WHERE > > > ("products"."id" = 1)--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This feels like a mistyped variable to me. Post the controller code for that action though, it''s probably a very simple little solution. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Lets have a look at your store controller... The nil happens here app/controllers/store_controller.rb:9:in `add_to_cart'' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---