2016-10-18 3 views
0

사용자가 기사에 댓글을 쓸 수있는 블로그 앱이 있으며 기사 작성자가 메시지 보내기 버튼을 추가 한 의견에서 직접 메시지를 보낼 수 있습니다. 메시지 옵션을 받고, 모든 일하고 있지만 문제가 때 메시지 단추를 또한 곱하여 얻을 여러 주석이 있지만 내가 뭘하려고하는지 각 주석에 대해 하나의 메시지 단추를 원하지 않습니다.동일한 작업에 대해 여러 개의 버튼 받기

이 지금 무엇을 얻고있다 : this is the problem

내 코드

<div id="comments"> 
    <h2 class="comment_count"> 
    <%= pluralize(@shipment.comments.count, "Bid") %> 
    </h2> 
    <% @comments.each do |comment| %> 
    <div class="comment"> 
     <li class="round-image-50"><%= image_tag(current_user.avatar.url(:thumb)) %></li><h6 class="username"><strong><font style="text-transform: capitalize;"><%= comment.user.full_name %></strong></font></h6> 
     <div class="shipment"> 
     <p class="content"> 
     <div class="text-center left col-md-4"> 
     <%= comment.content %> 
    </div> 
     <% if @shipment.user == current_user %> 
     <% @shipment.comments.each do |comment| %> 
     <%= link_to 'Send Message', new_conversation_path(recipient_id: comment.user_id), class: "btn btn-default btn-xs" %> 
     <% end %> 
     <% end %> 
    </p> 
    </div> 
    </div> 
     <% end %> 
    <%= render "comments/form" %> 
</div> 

답변

1

변경이 :

<% if @shipment.user == current_user %> 
    <% @shipment.comments.each do |comment| %> 
    <%= link_to 'Send Message', new_conversation_path(recipient_id: comment.user_id), class: "btn btn-default btn-xs" %> 
    <% end %> 
<% end %> 

<% if @shipment.user == current_user %> 
    <%= link_to 'Send Message', new_conversation_path(recipient_id: comment.user_id), class: "btn btn-default btn-xs" %> 
<% end %> 

PS : 나는 @comments이 표시된 코드에서 @shipment.comments과 동일한 것으로 가정

관련 문제