0
以下是我的結構:在導軌範圍內製作一個環路
具有與目標模型(destination_id)的belongs_to關聯的別墅模型。
具有與目的地模型的habtm關聯的用戶模型。
在我的索引視圖今天,我用:
<% current_user.destinations.each do |destination| %>
<% @villas.each do |villa| %>
<% if destination == villa.destination %>
<%= villa.name %>
<%end%>
<%end%>
<%end%>
這不是很清楚,這樣我就可以成爲一種範圍在我的別墅模型選擇別墅,其中目標ID == current_user.destinations?
非常感謝