我尝试验证属于另一个模型的属性的存在,但无济于事。
有
- 用户模型
- 轮廓模型
使用这种形式:
= simple_form_for(resource, :as => resource_name, :html => { :class => 'form-horizontal' } , :validate => true , :url => registration_path(resource_name)) do |f|
= f.input :username, :label => t(:username)
= f.input :email, :label => t(:email),
:hint => t(:hint_email_visible)
= f.input :password, :label => t(:password), :require => true
= f.input :password_confirmation, :label => t(:password_confirm)
- resource.build_profile
= f.fields_for :profile do |f|
#render
= f.hidden_field :form, :value => "signup"
.clear
= f.input :gender,
:label => t(:your_gender),
:collection => gender,
:item_wrapper_class => 'inline',
:as => :radio_buttons
.clear
= f.button :submit, t(:submit, :scope => :register) + " »"
如何使用上述表单设置验证性别字段的存在?