small medium large xlarge

21 Dec 2008, 13:34
Marc Gunton (8 posts)

Hey people,

Got an issue. I’ve copied and pasted all the code up to and including page 84 of the pdf to ensure its not a coding issue. When I hit refresh to see the price column I get the following error:


NoMethodError in Products#index Showing products/index.html.erb where line #21 raised:

undefined method `price’ for #

Extracted source (around line #21):

18: <td><%=h product.image_url %></td> 19: 20: <!-- START_HIGHLIGHT --> 21: <td><%=h product.price %></td> 22: <!-- END_HIGHLIGHT --> 23: <td><%= link_to ‘Show’, product %></td> 24: <td><%= link_to ‘Edit’, edit_product_path(product) %></td>

RAILS_ROOT: C:/Users/Marc/Documents/Aptana Studio/Techshop

C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/attribute_methods.rb:256:in method_missing' app/views/products/index.html.erb:21:in _run_erb_47app47views47products47index46html46erb’ app/views/products/index.html.erb:14:in each' app/views/products/index.html.erb:14:in _run_erb_47app47views47products47index46html46erb’ app/controllers/products_controller.rb:7:in index'-e:2:in load’-e:2

Request Parameters:


Show session dump

:csrf_id: 91c71a33902ca5790a10ad9222fa1059 flash: !map:ActionController::Flash::FlashHash {}

Response Headers:

{“cookie”=>[], “Content-Type”=>”text/html”, “Cache-Control”=>”no-cache”}


I’m using Aptana Studio with RadRails and configured it to use all the correct versions that the book requires so I’m pretty sure its not a ruby issue.

Any suggestions?



21 Dec 2008, 18:21
Matthew Slater (4 posts)

It’s trying to pull in product.price, but it’s not finding price. Do you have a column called price in your products table?

09 Jan 2009, 06:23
Terjin TJ Dhillon (13 posts)


From the look of things, you must’ve missed the migration that adds a column called price to the existing products table in the database.

You must be logged in to comment