我已經成功地實施了這些鏈接,登陸失敗後的輪廓自定義重定向...設計重定向登錄後無法使用閃光燈消息
Devise redirect after login fail https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated
但是我沒有在得到適當的提示信息我的靜態頁面。我試圖在這樣的custom_failure.rb加入了閃光燈消息...
def redirect_url
login_path
flash[:notice] = "Invalid login or password"
end
...但沒有雪茄。理想情況下,我想顯示默認的設計錯誤消息。任何方式來做到這一點?
...我還在我的應用程序的靜態頁面中顯示我的登錄和註冊頁面。因此,對於在應用程序/視圖/ static_pages/login.html.erb我有實例化......
<%= form_for("user", :url => user_session_path) do |f| %>
<table>
<tr>
<td><%= f.label :email %></td>
<td><%= f.text_field :email %></td>
</tr>
<td><%= f.label :password %></td>
<td><%= f.password_field :password %></td>
</table>
<%= f.check_box :remember_me %>
<%= f.label :remember_me %><p/>
<%= f.submit 'Sign in' %><p/>
<%= link_to "Forgot your password?", new_password_path('user') %>
<% end %>
測試
感謝您的回覆馬里奧。我嘗試了你的建議,但確實奏效。你能想出任何原因嗎?感謝名單! – Lumbee 2012-01-04 21:04:08
不是真的,您的應用程序是否使用您創建的自定義失敗類?你可以嘗試在響應方法中加一個加號以確保代碼正在運行嗎? – 2012-01-05 01:43:50
嘿,馬里奧,看了這一些後,我認爲這個問題是在視圖中。我不需要在視圖中顯示閃光信息的東西嗎?這裏是我的觀點看起來像哪個是app/views/static_pages/login.html.erb https://gist.github.com/1565343 – Lumbee 2012-01-05 13:50:27