RoR新手在這裏。在Agile Web Dev with Rails的第9章結束時使用「play time」練習。無法獲取link_to_remote以在部分中爲我生成鏈接。我store_cart_item.html.erb部分看起來像這樣:Rails link_to_remote無法渲染,爲什麼?
<% if cart_item == @current_item then %>
<tr id="current_item">
<% else %>
<tr>
<% end %>
<td>
<!-- stuck here, trying to get a link to decrement the quantity, but it doesn't
even show a link, I also tried nesting a link_to in form_remote_tag which
at least displayed link but didn't call the remove_from_cart action -->
<% link_to_remote cart_item.quantity.to_s + "×",
:update => "cart",
:url => {:action => "remove_from_cart", :id => cart_item.product} %>
</td>
<td><%= h cart_item.title %></td>
<td class="item-price"><%= number_to_currency(cart_item.price) %></td>
</tr>
在瀏覽器中,link_to_remote似乎無所事事,B/C HTML輸出如下:
<tr>
<td>
<!-- stuck here, trying to get a stupid link to decrement the quantity, doesn't even show link
also tried nesting it in form_remote_tag which at least displayed link but didn't call the
remove_from_cart action -->
</td>
<td>Agile Web Development with Rails</td>
<td class="item-price">$68.85</td>
</tr>
感覺就像我錯過了非常明顯的事情我究竟做錯了什麼?
哦,我覺得像這樣的混日子。謝謝您的幫助。 – Marvin 2010-07-17 22:24:54