cancan authlogic gem's edit current user profile error
Once I added the cancan Gem to my authlogic authorisation system, I started running into problems. My link_to edit current user profile died!
code:
#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
I have tried many ways to get the current user id to the edit link nothing works has anyone have any ideas?
开发者_如何学CRegards
Dan
I doubt you want to be passing the :current
symbol to your edit_user_path
. You likely want to have edit_user_path(current_user)
.
精彩评论