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?
感谢