cancan authlogic gem编辑当前用户配置文件错误

时间:2010-02-28 18:03:54

标签: ruby-on-rails

一旦我将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转到编辑链接没有任何人有任何想法吗?

此致

1 个答案:

答案 0 :(得分:3)

我怀疑您是否希望将:current符号传递给edit_user_path。您可能希望拥有edit_user_path(current_user)

相关问题