0

そのクライアントの場所に移動するインデックス リスト内の各クライアントのボタンを設定しようとしています。

これは私のコードです:

  <% Client.active.find_each do |client| %>
<tr>
<td><strong><%= link_to client.client_name, client_path(client) %></strong></td>
<td><%= client.locname %></td>
<td><%= client.phone1 %></td>
<td><%= client.fax %></td>
<td><%= client.worequests.notcompl.count %></td>
<td><%= client.workorders.count %></td>
<td><%= client.contacts.count %></td>
  <% location = Location.where('locname' == client.locname).first.id %>
  <td><%= link_to 'Tree', location_url(location), :class => 'btn btn-mini btn-primary' %></td>
  <% if current_user.has_role? :admin or current_user.has_role? :super %>
    <td><%= link_to 'Edit', edit_client_path(client), :class => 'btn btn-mini btn-success' %></td>
  <% else %>
    <td></td>
  <% end %>
 </tr>
<% end %>

ただし、リンクは常に location/13 (最初の location.where ルックアップからのもの) です。

各クライアントのツリー ボタンがその場所を指していないのはなぜですか?

ご協力いただきありがとうございます!

4

2 に答える 2