I just upgrade my application to rails 4.1.0.beta1
I have a class
class User < ActiveRecord::Base
enum usertype: { :employee => 10, :boss => 30, :manager => 40, :admin => 50 }
}
Does the whole enumeration function work well, like user.boss? # ture
But when I try to get all types of users using
User.usertypes
I have an undefined method for "usertypes"
Any help?
This is the link I learned from http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html
Edit: Migration
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :email
t.string :password_digest
t.string :remember_token
t.boolean :is_locked
t.integer :usertype, default: 10
t.timestamp :last_login_at
t.timestamps
end
end
end
etlds source
share