我希望能够获取与搜索关键字匹配的主题名称的所有配置文件。现在我正在加载所有配置文件。请问如何实现?非常感谢任何帮助。
Profile.rb
has_many :categorizations
has_many :subjects, through: :categorizations
Subject.rb
has_many :categorizations
has_many :profiles, through: :categorizations
Categorization.rb
belongs_to :profile
belongs_to :subject
views/search/index.html.erb
# search form
<%= form_tag search_index_path, :method => 'get' do %>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "search", :name => nil %>
<% end %>
# search results
<% @profiles.each do |profile| %>
<%= profile.name %>
<% end %>
search_controller.rb
def index
@profiles = Profile.with_translations('en').all
end