У меня есть модель профиля:
has_one :job_preference, inverse_of: :profile, dependent: :destroy
accepts_nested_attributes_for :job_preference, reject_if: :all_blank, allow_destroy: true
Модель предпочтений работы:
belongs_to :profile
has_many :job_preferences_wanted_locations
has_many :wanted_locations, through: :job_preferences_wanted_locations, dependent: :destroy
Предпочтения работы Требуемая модель местоположения:
class JobPreferencesWantedLocation < ApplicationRecord
belongs_to :job_preference
belongs_to :wanted_location
accepts_nested_attributes_for :wanted_location
end
Требуемая модель местоположений:
class WantedLocation < ApplicationRecord
has_many :job_preferences_wanted_locations
has_many :job_preferences, through: :job_preferences_wanted_locations, dependent: :destroy
end
Я пытаюсь использовать Ransack gem в индексе профиля, чтобы сделать запрос о разыскиваемых местах.
Я могу получить доступ к этим разыскиваемым местам, например так:
profile.job_preference.wanted_locations.each do |n|
print n.name
end
Я прочитал документ Ransack и попробовал варианты:
job_preference_wanted_location_name_cont
, но, похоже, это не работает.