School
モデルとモデルの2つのモデルがありPrice
ます。すべての学校には価格があります。その価格で検索結果学校に戻りたいと思います。レールとサンスポットを使用しています。
学校の管理者:
class SchoolsController < ApplicationController
def index
@query = params[:search]
@search = School.search do
fulltext params[:search]
paginate :page => params[:page], :per_page => 7
end
@results = @search.results
end
end
学校モデル:
class School < ActiveRecord::Base
has_many :prices
# sunspot search
searchable do
text :name, :locality
end
end
インデックス-表示
<% for result in @results %>
<tr>
# School name, from the school-model
<td><h3><%= link_to result.name, result %></h3></td>
# School price, from the price-model
<td><h3><%= result.prices.min %> kr</h3></td>
</tr>
<% end %>
黒点を使用して、すべての学校の価格を返すにはどうすればよいですか?