2
我有這種形式的部分:如何正確地在一個視圖中結合登錄和註冊表格
.row
.span6
.well
%h2 Sign in
= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-vertical' }) do |f|
= f.input :email, :autofocus => true, :wrapper => :bootstrap_placeholder
= f.input :password, :wrapper => :bootstrap_placeholder
= f.input :remember_me, :as => :boolean if devise_mapping.rememberable?
= f.button :submit, "Sign in", :class => 'btn-primary'
= render "devise/shared/links"
.span6
.well
%h2 Sign up
= simple_form_for(resource, :as => resource_name, :url => regi stration_path(resource_name), :html => {:class => 'form-vertical' }) do |f|
= f.error_notification
= display_base_errors resource
= f.input :name, :autofocus => true
= f.input :email, :required => true
= f.input :password, :required => true
= f.input :password_confirmation, :required => true
= f.button :submit, 'Sign up', :class => 'btn-primary'
= render "devise/shared/links"
,其工作正常,但問題來了與驗證,當我想不輸入任何數據來註冊用戶。 ..顯示錯誤消息,但它也着重登錄形式的用戶名和密碼字段..有沒有辦法避免這種驗證混淆?
謝謝!我解決了它,但錯誤只顯示當我將simple_form_for標記更改爲:simple_form_for(@login_resource || resource ... –