0

I've a problem Rolify. When I use the command rake db:reseed in the shell, to reset my database I have this error:

undefined local variable or method `rolify' for Customer:Class

Here's my code in my model with Rolify:

class Customer
  include Mongoid::Document
  include Mongoid::Timestamps
  rolify
  embeds_one :contact
  has_many :orders

  devise :database_authenticatable, :recoverable, :registerable, :timeoutable, :validatable,
         :token_authenticatable, :confirmable

  attr_accessible :email, :password, :password_confirmation, :add_role

  field :first_name
  field :last_name
  field :password
  field :gender
  field :confirmed_at
  field :unconfirmed_email
  field :confirmation_url
  field :confirmation_token
  field :confirmation_sent_at
  field :email
  field :encrypted_password

  gender_regex = /^(Male|Female)$/

  validates :first_name, presence: true, :allow_blank => true
  validates :last_name, presence: true, :allow_blank => true
  validates :password, presence: true
  validates :gender, presence: true, :allow_blank => true,
                     format: { with: gender_regex }
end

If you know why, please help me :)

4

2 回答 2

0

It might be late to answer, but for the sake of others who might still be facing this kind of problem.

I fixed this by restarting my server after adding rolify and resourcify in models.

于 2013-09-05T20:04:08.060 回答
0

rolify从您的Customer模型中删除。
您需要按照https://github.com/EppO/rolify上的说明进行操作

您应该将其包含在Gemfile您的模型中而不是模型中:

gem "rolify"

在要应用角色的资源模型中,必须包括:

resourcify

我觉得是你的错......

于 2012-06-24T21:51:20.390 回答