0

I am getting the following error, please any one view it and help me out of this.. Actually this is the error shown in my development.log file.

ActionView::Template::Error (undefined method `quantity' for #<LineItem:0xaa47b1c>):
4: <tr>
5: <% end %>
6: <tr>
7: <td><%= line_item.quantity %>&times;</td>
8: <td><%= line_item.product.title %></td>
9: <td class="item_price"><%= number_to_currency(line_item.total_price) %></td>
10: </tr>
  app/views/line_items/_line_item.html.erb:7:in `_app_views_line_items__line_item_html_erb___826332857_89103730'
  app/views/carts/_cart.html.erb:4:in `_app_views_carts__cart_html_erb___185026047_87767060'
  app/views/layouts/application.html.erb:19:in `_app_views_layouts_application_html_erb___370633105_87583010'
  app/helpers/application_helper.rb:6:in `hidden_div_if'
  app/views/layouts/application.html.erb:18:in `_app_views_layouts_application_html_erb___370633105_87583010'

1 Answer 1

0

The error's quite clear: your LineItem class does not have a method (or database field) called quantity.

4
  • 'rails generate migration add_quantity_to_line_items quantity:integer' I used this in the command line already to create database field quantity...should I do any thing more.. Mar 22, 2013 at 10:56
  • Have you actually updated the database with rake db:migrate?
    – Chowlett
    Mar 22, 2013 at 11:13
  • I resolved the error, even though I gave quantity field , it didnt go into the database. I deleted the migration field and then re-generated it. Thanq Mar 22, 2013 at 12:10
  • Yup, sounds like you didn't run rake db:migrate. Glad to help. (Remember you can mark my answer as "Helpful" by clicking the up-arrow; and "Accepted" by clicking the tick.)
    – Chowlett
    Mar 22, 2013 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.