moh*_*mun 2 ruby-on-rails ransack
用户 has_many 个人资料和个人资料 has_many 电子邮件地址。我有用户搜索表单,我有电子邮件字段。我怎样才能做到这一点。
form_for @User.search do |U|
f.text_field :name, :name_cont
f.text_field :email, #what should I write here?
Run Code Online (Sandbox Code Playgroud)
小智 7
我不确定这是否是完美的方法。您可以尝试添加一个
has_many :email, through: profiles
在用户模型中。完成此操作后,您可能需要做的就是,:user_emails_cont
也试一试:user_profiles_emails_cont
,没有很多的通过关系。