开发者

cancan authlogic gem's edit current user profile error

开发者 https://www.devze.com 2022-12-21 23:29 出处:网络
Once I added the cancan Gem to my authlogic authorisation system, I started running into problems. My link_to edit current user profile died!

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?

开发者_如何学C

Regards

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消