我在Rails& amp;设计。不知何故,我无法在本地注册新用户。我可以通过控制台注册用户。目前这一切都有效。
我的routes.rb
看起来像这样:
devise_for :users,:path => '', :path_names => {:sign_in => 'eisodo',
:sign_out => 'exodo', :sign_up => 'register'},
:controllers => { :registrations => "registrations" }
我在这里检查了类似的问题并遵循了一些建议:我已将resources :users
添加到routes.rb
文件以及devise_for:users, "path_prefix"
但我仍然无法让它发挥作用。
我的ability.rb
文件如下所示:
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.role == "admin"
can :manage, :all
elsif user.role == "manager"
can [:read, :update, :create], [Job, Equipment]
#can [:read, :update, :create], [Equipment]
elsif user.role == "employee"
can [:read, :update, :create], [Equipment, Job]
cannot [:create], [Job]
#can [:read, :update], [Equipment]
end
end
end
有人解决了这个问题吗?