我有一个具有多对多关系的篮球应用程序,其中一名教练可以执教多个球队,而一个球队可以有许多教练。
Coaches_Controller.rb
def index
@coaches = Coach.joins(:teams).select("coaches.first_name, coaches.last_name, teams.team_level")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @coaches }
end
end
索引.html.erb
<% @coaches.each do |coach| %>
<tr>
<td><%= link_to coach.first_name, coach_path(coach) %></td>
<td><%= coach.last_name %></td>
<td><%= coach.team_level %></td>
<td>
<%= link_to t('.edit', :default => t("helpers.links.edit")),
edit_coach_path(coach), :class => 'btn btn-mini' %>
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
coach_path(coach),
:method => :delete,
:confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
:class => 'btn btn-mini btn-danger' %>
</td>
</tr>
<% end %>
我收到了这个错误,我不太清楚为什么......
http://i.stack.imgur.com/5a6oB.png
想法?我觉得这是我没有看到的小东西......谢谢!