你知道我会做错什么吗?我知道说ability.can?:manage没有多大用处,但是我只是想开始使用CanCan。
我确实有宝石,并且已经运行生成cancan:能力。
谢谢。
错误和代码:
未初始化的常量constant::CanCan提取的源代码(在第4行附近):
1:
2: <% if current_user %>
3: <p>Currently logged in as <strong><%= current_user.email %></strong></p>
4: <% current_ability = Ability.new(current_user) %>
5: <%if can? :manage, :all %>
6: <p>Hey Buddy, You're Authorized ;)</p>
7: <% end %>发布于 2012-06-12 05:07:59
我收到这个错误是因为我的Gemfile将CanCan需求放在了测试环境中没有加载的组中。
尝试检查您的CanCan需求是否已加载到您正在运行的环境中。此要求将加载默认组中的CanCan:
# project_root/Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'cancan'https://stackoverflow.com/questions/10921762
复制相似问题