small medium large xlarge

12 Feb 2010, 12:09
LuisRuby (4 posts)

Congratulations for the excellent book! I’m using Ubuntu and had to install curl using sudo apt-get install curl. Trying the command, at page 179 (paper version): curl http://localhost:3000/info/who_bought/3 I got a lot of messages starting with html code:

Action Controller: Exception caught

…. NoMethodError in InfoController#who_bought … undefined method ‘orders’ … ‘method missing’ …. wow! a lot of them! Using ruby script/about, I get: Ruby version 1.8.7 RubyGems version 1.3.5 Rack version 1.0 Rails version 2.3.5 Active Record 2.3.5 Active Resource 2.3.5 Active Mailer 2.3.5 Active Support 2.3.5 Application root /home/luiz/work/depot Environment development Database adapter sqlite3

It seems I’m missing something! Could someone help me? Thank you very much!

12 Feb 2010, 13:19
Sam Ruby (634 posts)

I’d need to see just a bit more information.

The key is the information you provided is NoMethodError in InfoController#who_bought and undefined method ‘orders’. If you look in app/controllers/info_controller.rb, you should see a line like @orders = @product.orders, and that should match the line number in the stack traceback.

What’s likely going on is that @product isn’t an instance of a Product (unlikely), or that Product doesn’t have an orders attribute defined. Just before this step, you were instructed to add a line that looks like has_many :orders, :through => :line_items. Is this line present?

If everything checks out, try restarting your server to ensure that the changes you made were picked up.

12 Feb 2010, 18:06
LuisRuby (4 posts)

Thank you Sam! Yes, that line has_many :orders, :through => :line_items was not present. Probably I was sleeping :-). Now it is working! Thank you very much!

You must be logged in to comment