1
我使用Devise爲我的登錄。除了一個例外,一切正常。如果用戶在登錄頁面輸入錯誤或沒有值,則什麼都不會發生。沒有錯誤或錯誤信息(使用正確的數據登錄正常工作)。沒有驗證錯誤與設計
我只在/ session/new頁面上有這個問題。
這是我的看法
.container
.row.text_content_top
.alert.alert-danger
%button.close{ type: "button", "data-dismiss" => "alert"} ×
= devise_error_messages!
.row.text_content_top
.col-md-4.col-md-offset-4
%h2 Sign in
.row.text_content
.col-md-4.col-md-offset-4.well
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
= devise_error_messages!
.input-group.has-feedback
%span.input-group-addon
%i.fa.fa-envelope-o.fa-fw
= f.label :email, class: 'sr-only'
= f.email_field :email, autofocus: true, class: 'form-control', placeholder: 'E-Mail'
.input-group.has-feedback.top-buffer-10
%span.input-group-addon
%i.fa.fa-key.fa-fw
= f.label :password, class: 'sr-only'
= f.password_field :password, autocomplete: 'off', class: 'form-control', placeholder: 'Password'
= f.submit "Login", class: 'btn btn-success btn-large top-buffer-10'
= link_to "Forgot your password?", new_password_path(resource_name), class: 'top-buffer-10'
而且我的模型
class User < ActiveRecord::Base
has_many :orders
validates :email, presence: true, uniqueness: true
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :lockable
end
我在控制器或其他自定義代碼
THX無碼提前
[這個答案](http://stackoverflow.com/a/4640633/2856441)的問題,問同樣的事情爲我工作。 –
@ JKen13579的鏈接也是我們使用的! Devise不使用Rails中的標準Flash對象 –
Thx JKen13579這可以正常工作 – ThreeFingerMark