Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CreateUsers < ActiveRecord::Migration
- class Role < ActiveRecord::Base
- end
- class User < ActiveRecord::Base
- attr_accessor :password
- end
- def self.up
- create_table :users do |t|
- t.column :name, :string
- t.column :email, :string
- t.column :hashed_password, :string
- t.column :last_login, :datetime
- t.column :role_id, :integer
- t.column :activation_code, :string, :limit => 40
- t.column :activated_at, :datetime
- end
- roles = ["Super User", "Admin", "User (normal)", "User (privileged)"]
- roles.each do |r|
- role = Role.create(:name => r)
- end
- user = User.new(:name => "Craig Mackenzie", :email => "cm@impact-im.co.uk", :password => "password", :role_id => 1 )
- user.save
- user.activate
- end
- def self.down
- drop_table :users
- end
- end
Add Comment
Please, Sign In to add comment