User has_many profiles and profile has_many email address. I have search form for User and I have field for email. How can I achieve this.
form_for @User.search do |U|
f.text_field :name, :name_cont
f.text_field :email, #what should I write here?
I'm unsure if this is the perfect way to do it. You can try adding a
has_many :email, through: profiles
in the User model. After doing this, all you might have to do is, :user_emails_cont
Also try :user_profiles_emails_cont
, without the has many through relationship.
Example override in the model :
ransacker :devices_count, formatter: proc{ |v|
data = ContractSection.csa.includes(:contract_section_devices)
.where("
(select count(*) from contract_section_devices
where contract_section_devices.contract_section_id = contract_sections.id) = #{v.to_i}
").map(&:id)
} do |parent|
parent.table[:id]
end
views: :devices_count_in
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.