我正在使用带有 Postgresql 的 Rails 3,并且我有一个使用两个迁移定义的用户表(这是两个 self.up 方法):
def self.up
create_table(:users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.timestamps
end
def self.up
add_column :users, :admin, :boolean, :default => false
end
现在,当我去尝试使用管理员用户播种时,如下所示:
User.create(:username => "admin", :email => "foobar@gmail.com",:password => "password", :password_confirmation => "password", :admin => true)
即使我指定了 true,它也会创建一个 admin 等于 false 的用户。我应该首先创建 User.new 并设置管理员还是一起摆脱默认设置?