Skip to content

Commit

Permalink
Create the User model w/ name, email & password
Browse files Browse the repository at this point in the history
  • Loading branch information
pgaspar committed Aug 1, 2017
1 parent 3a4802e commit bb3ea58
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
Expand All @@ -55,4 +55,4 @@ end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'graphiql-rails', group: :development
gem 'graphiql-rails', group: :development
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GEM
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
arel (8.0.0)
bcrypt (3.1.11)
bindex (0.5.0)
builder (3.2.3)
byebug (9.0.6)
Expand Down Expand Up @@ -177,6 +178,7 @@ PLATFORMS
ruby

DEPENDENCIES
bcrypt (~> 3.1.7)
byebug
capybara (~> 2.13)
coffee-rails (~> 4.2)
Expand Down
6 changes: 6 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class User < ApplicationRecord
has_secure_password

validates :name, presence: true
validates :email, presence: true, uniqueness: true
end
11 changes: 11 additions & 0 deletions db/migrate/20170801015006_create_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateUsers < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :password_digest

t.timestamps
end
end
end
10 changes: 9 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170730185849) do
ActiveRecord::Schema.define(version: 20170801015006) do

create_table "links", force: :cascade do |t|
t.string "url"
Expand All @@ -19,4 +19,12 @@
t.datetime "updated_at", null: false
end

create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"
t.string "password_digest"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

end
11 changes: 11 additions & 0 deletions test/fixtures/users.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
name: MyString
email: MyString
password_digest: MyString

two:
name: MyString
email: MyString
password_digest: MyString
7 changes: 7 additions & 0 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit bb3ea58

Please sign in to comment.