3
我有一個類用戶在Rails中使用Mongoid和Devise。我似乎無法弄清楚如何添加管理員角色。 platformtec(設計)網站上的How to要我運行標準的Rails遷移,但由於Mongoid,這不起作用。如何將管理添加到設計Rails/Mongoid用戶類?
任何人都可以指向正確的方向嗎?
這裏是我的user.rb(減去註釋掉模塊):
class User
include Mongoid::Document
# Include default devise modules.
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
## Database authenticatable
field :email, :type => String, :null => false, :default => ""
field :encrypted_password, :type => String, :null => false, :default => ""
## Recoverable
field :reset_password_token, :type => String
field :reset_password_sent_at, :type => Time
## Rememberable
field :remember_created_at, :type => Time
## Trackable
field :sign_in_count, :type => Integer, :default => 0
field :current_sign_in_at, :type => Time
field :last_sign_in_at, :type => Time
field :current_sign_in_ip, :type => String
field :last_sign_in_ip, :type => String
## Token authenticatable
# field :authentication_token, :type => String
field :name
validates_presence_of :name
validates_uniqueness_of :name, :email, :case_sensitive => false
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
end
感謝, 查理·馬吉
Duh。該死的。我忘了在布爾中大寫B。我覺得自己像個白癡。謝謝Shingara。 – charliemagee 2012-03-28 23:45:02
你需要傳遞一個類,所以它是一個常量。 Ruby中的一個常量始終以大寫字母開頭:) – shingara 2012-03-29 07:35:08