В моем проекте Rails, я пытаюсь настроить аутентификацию пользователей и ролей пользователей с помощью следующих Gems:Неопределенное локальная переменная или метод «rolify»
- DEViSE
- Канкан
- Rolify
У меня был разработан и работал отлично, но потом, когда я пошел на создание CanCan и Rolify, я получаю эту ошибку в браузере :
NameError in Home#index
Showing C:/Sites/JustManage/app/views/devise/menu/_registration_items.html.erb where line #1 raised:
undefined local variable or method `rolify' for #<Class:0x3f48660>
Extracted source (around line #1):
1: <% if user_signed_in? %>
2:
3: <li>
4: <%= link_to('Edit registration', edit_user_registration_path) %>
Trace of template inclusion: app/views/layouts/application.html.erb
Rails.root: C:/Sites/JustManage
user.rb
class User < ActiveRecord::Base
rolify
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :subdomain, :first_name, :last_name
# Make sure certain attributes are unique
validates_uniqueness_of :email, :case_sensitive => false
end
role.rb
class Role < ActiveRecord::Base
has_and_belongs_to_many :users, :join_table => :users_roles
belongs_to :resource, :polymorphic => true
scopify
end
rolify.rb
Rolify.configure do |config|
config.use_dynamic_shortcuts
end
Дайте мне знать, если вам нужно, чтобы я отправлял сообщения из любых других файлов!
Я добавил камень 'rolate' в свой' gemfile', затем я сгенерировал роль, используя 'rails generate rolify: role'. –
Когда я добавил 'require 'rolify' в начало моего файла' user.rb', я получил эту ошибку: 'не могу загрузить такой файл - rolify' –
Вам нужно запустить' bundle install' после того, как вы добавите драгоценный камень к вашему Gemfile. – grenierm5