2010-11-07 74 views
1

我正在嘗試使用user_signed_in?到登錄區域添加到我的軌道使用3個應用程序設計1.1.3,我得到一個NoMethodErrorin規則#指數設計:NoMethod錯誤&user_signed_in

<% if user_signed_in? -%> 
<div id="user_login_box" style="float:right"> 
    <%= current_user.email %> | 
    <%= link_to 'My info', edit_user_registration_path %> | 
    <%= link_to 'Sign out', destroy_user_session_path %> 
</div> 
<% end -%> 

我不知道什麼是錯的究竟,但顯然沒有被使用的色器件的方法。我也相當(閱讀:真的)新的鐵軌,並沒有用過之前的設計。

+0

如果你刪除'user_signed_in?'並登錄,並進入顯示你提到的視圖的頁面,是否顯示了<%= current_user.email%>? – Zabba 2010-11-07 04:44:59

+0

不是。我得到這個: 未定義的局部變量或方法'current_user'爲#<#:0xab962d4> – SpaceGhost 2010-11-07 05:08:48

回答

1

您的User型號似乎缺少devise :database_authenticatable的呼叫。

此外,上手製定一個好辦法是由Ryan貝茨看優秀RailsCasts:Introducing Devise

3

我有完全一樣的問題。 undefined local variable or method 'edit_user_registration_path'

但是,我有devise :database_authenticatable,但不是:registerable。在我加入:registerable之後,一切正常!

1

它也可能發生,你試圖從另一個引擎調用該路由,所以在這種情況下,你必須指定該路由的上下文,如main_app.edit_user_registration_path