2010-07-14 4 views
0

RoR 신참 여기에 있습니다. Agile Web Dev with Rails, 9 장 끝에있는 "play time"연습. 부분적으로 나를 위해 링크를 생성하는 link_to_remote를 얻을 수 없습니다. 이 같은 내 store_cart_item.html.erb 부분 외모 : 내가 좋아Rails link_to_remote 렌더링에 아무런 이유가없는 이유는 무엇입니까?

<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> 

이 온도 : 브라우저에서

<% 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 + "&times;", 
       :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는 HTML 출력은 다음과 같습니다 C/B, 아무것도하지 않고있는 것으로 보인다 정말 분명한 것을 놓치고. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

답변

2

태그 <% exp %> 아래의 표현식은 값을 할당하지 않고 평가됩니다.

<%= exp %> 

그냥 아, 나는 그런 노는 것 같은 느낌

<%= link_to_remote cart_item.quantity.to_s + "&times;", 
       :update => "cart", 
       :url => {:action => "remove_from_cart", :id => cart_item.product} %> 
+0

하는 코드를 변경 같은

그리고 사용하거나 식의 값을 표시하려면 그냥 "="를 사용하여 서명. 도와 주셔서 감사합니다. – Marvin

2

<% link_to_remote %> 대신 <%= link_to_remote ... %>을 사용하십시오 (예 : 레일스 2.x 또는 이전 버전 사용).

관련 문제