2010-02-28 106 views
2

一旦我将cancan Gem添加到我的authlogic授权系统中,我开始遇到问题。我的link_to编辑当前用户配置文件已死!cancan authlogic gem's编辑当前用户配置文件错误

代码:

#application.html.erb 

<%= link_to "Edit Profile", edit_user_path(:current) %> 

#ApplicationController 

private 
    def current_user_session 
    return @current_user_session if defined?(@current_user_session) 
    @current_user_session = UserSession.find 
    end 


    def current_user 
    return @current_user if defined?(@current_user) 
    @current_user = current_user_session && current_user_session.record 
    end 

    rescue_from CanCan::AccessDenied do |exception| 
    flash[:error] = "Access denied." 
    redirect_to root_url 
    end 

error: 

ActiveRecord::RecordNotFound in UsersController#edit 

Couldn't find User with ID=current 

我已经尝试了许多方法来获得当前用户ID的修改链接没有什么作品有没有人有什么想法?

问候

+0

也许Rails不知道什么是':current'符号?你也可以从'UsersController'添加一些代码,因为它说错误在这个控制器中。 – klew 2010-02-28 18:29:04

回答

3

我怀疑你想传递:current符号添加到您edit_user_path。你可能想要有edit_user_path(current_user)

+0

谢谢Bensie,我在这里呆了3个小时,不爽! 我很高兴你在哪里帮助再次感谢! – MrThomas 2010-02-28 20:40:58

相关问题