Created
September 2, 2016 01:03
-
-
Save byronmejia/af5507b5f340bb8bacba45c7bdc22fc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Migration (This sits in db/migration folder) ------------------------- | |
Sequel.migration do | |
up do | |
# Create Users table | |
create_table(:logins) do | |
primary_key :id | |
String :user_name, unique: true, null: false | |
String :password_hash, null: false | |
end | |
end | |
down do | |
drop_table(:logins) | |
end | |
end | |
# ORM (This sits in models folder) --------------------------------- | |
class Login < Sequel::Model | |
plugin :secure_password, cost: 12, digest_column: :password_hash | |
end | |
# Seed (This sits in db/seed.rb) ------------------------------------- | |
require_relative '../app/app' | |
login = Login.new | |
login.user_name = 'admin' | |
login.password = 'password' | |
login.password_confirmation = 'password' | |
puts 'Created Login' if login.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment