1. NoMethodError in StoreController#add_to_cart
undefined method `product' for #<Product:0x4a02900>
[color=red]Reason : [/color]
Session Problem
[color=red]Solution:[/color]
clean the session and retart the server
rake db:sessions:clear
2. Cart.Item nil.object found when use the redirect_to_index
[color=red]reason:[/color]
Session not loaded by the redirect.
[color=red]Solution:[/color]
def index
@products = Product.find_products_for_sale
@cart = find_cart
end
3. Submit Button doesn't display when trail on the AJax sample
[color=red]Reason:[/color]
version problem, and the tag name is not correct
[color=red]Solution:[/color]
<%= form_remote_tag :url => { :action => :add_to_cart, :id => product } %>
<%= submit_tag "Add to Cart" %>
<%= end_form_tag %>
undefined method `product' for #<Product:0x4a02900>
[color=red]Reason : [/color]
Session Problem
[color=red]Solution:[/color]
clean the session and retart the server
rake db:sessions:clear
2. Cart.Item nil.object found when use the redirect_to_index
[color=red]reason:[/color]
Session not loaded by the redirect.
[color=red]Solution:[/color]
def index
@products = Product.find_products_for_sale
@cart = find_cart
end
3. Submit Button doesn't display when trail on the AJax sample
[color=red]Reason:[/color]
version problem, and the tag name is not correct
[color=red]Solution:[/color]
<%= form_remote_tag :url => { :action => :add_to_cart, :id => product } %>
<%= submit_tag "Add to Cart" %>
<%= end_form_tag %>
本文介绍了Rails应用中遇到的购物车相关错误及解决方案,包括NoMethodError、Cart.Item nil对象问题及SubmitButton显示异常的原因与解决办法。
1266

被折叠的 条评论
为什么被折叠?



