1
我有以下幾點:
class Person < ActiveRecord::Base
has_many :educations
end
class Education < ActiveRecord::Base
belongs_to :school
belongs_to :degree
belongs_to :major
end
class School < ActiveRecord::Base
has_many :educations
# has a :name
end
我希望能夠重返誰去一個特定的學校,所以我把PeopleController#索引我所有的人有
@search = Person.search do
keywords params[:query]
end
@people = @search.results
如何在Person模型上創建可搜索的方法以進入學校?難道我做這樣的事情:
searchable do
text :school_names do
educations.map { |e| e.school.name }
end
end
,我最終會與教育(學位等),每個屬性做或我可以做一個搜索的方法教育和莫名其妙「呼叫」,從Person.searchable?
感謝