I am following the â€œAgile Web Development with Railsâ€ and I have decided to deviate from the book a bit to discover Rails plugins. I have set up my app to use â€œpaperclipâ€ to size my photos. I have managed to get the app working on part of my application. But...Im getting this error. NoMethodError in Store#index You have a nil object when you didn't expect it! The error occurred while evaluating nil.photo Extracted source (around line #5): This is my code: <h1>New Products on Display</h1> <% for product in @products -%> <div class="entry"> <%= image_tag @product.photo.url ( :small) %> <---- (error here) <h3><%=h product.title %></h3> <%= product.description %> <div class="price-line"> <span class="price"><%= number_to_currency(product.price) %></span> <%= button_to "Add to Cart" %> </div> </div> <% end %> This is my first post: Let me know if you guys need more information. Thanks for the help.
on 2009-05-28 20:45
on 2009-05-28 21:17
On May 28, 2009, at 11:45 AM, Michael Michael wrote: > NoMethodError in Store#index > > <% for product in @products -%> > > <div class="entry"> > > <%= image_tag @product.photo.url ( :small) %> @product should be product without the @.
on 2009-05-28 21:34
Perfect... It works now! Thank you for helping me out Philip