2010-11-07 72 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