一旦我将cancan Gem添加到我的authlogic授权系统,我开始遇到问题。我的link_to编辑当前用户个人资料已经死亡!
代码:
#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 :(得分:3)
我怀疑您是否希望将:current
符号传递给edit_user_path
。您可能希望拥有edit_user_path(current_user)
。