[转载]AJAX error: ActionView::TemplateError (undefined method `[]'..

Hi!
I got an error in my app, when Im adding a produt to my cart Im using some AJAX to first show the cart and then lighten up the new added product in the cart.
But when i add a new product to cart; I have to refresh my page so I can see the new product, because the AJAX doesnt work... It works on my development computer but not in the production server, maybe its something with the new Ruby version: 1.8.7.
Is this code correct?!
My add_to_cart.rjs:
page.select("div#notice").each { |div| div.hide } <--- If cart is empty it doesnt show the cart
page.replace_html("cart", :partial => "cart", :object => @cart)
page[:cart].visual_effect :blind_down if @cart.total_items == 1
page[:current_item].visual_effect :highlight,
:startcolor => "#8a9546",
:endcolor => "#efeab0"

From the production.LOG
[code=]Processing StoreController#add_to_cart (for 83.254.103.73 at 2009-02-17 22:00:11) [POST]
Session ID: BAh7CDoMY3NyZl9pZCIlYjY4Mzk0M2JlM2YyZTg3OWRlMzc4ZWU5ZDc5ZmUx%0AYmQ6CWNhcnRvOglDYXJ0BjoLQGl0ZW1zWwAiCmZsYXNoSUM6J0FjdGlvbkNv%0AbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA%3D--eb9fcfaa057def84ec7387692c8ff4084cfd8f7d
Parameters: {"commit"=>"K
Last edited by depe86 (2009-02-18 14:03:38)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

At last I got the error fixed. I think I was trying for 24h
The problem is with the AJAX function "page.select" when using Ruby 1.8.7...
Copy this code to the environment.rb.
unless '1.9'.respond_to?(:force_encoding)
String.class_eval do
begin
remove_method :chars
rescue NameError
# OK
end
end
end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值