Complete Lesson 26
This commit is contained in:
parent
c3fbb70cff
commit
014c15fe4e
2
Gemfile
2
Gemfile
@ -34,7 +34,7 @@ gem "jbuilder"
|
||||
# gem "kredis"
|
||||
|
||||
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
|
||||
# gem "bcrypt", "~> 3.1.7"
|
||||
gem "bcrypt"
|
||||
|
||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
|
||||
|
@ -70,6 +70,7 @@ GEM
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
autoprefixer-rails (10.4.15.0)
|
||||
execjs (~> 2)
|
||||
bcrypt (3.1.19)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.16.0)
|
||||
msgpack (~> 1.2)
|
||||
@ -225,6 +226,7 @@ PLATFORMS
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
bcrypt
|
||||
bootsnap
|
||||
bootstrap
|
||||
capybara
|
||||
|
2
app/controllers/users_controller.rb
Normal file
2
app/controllers/users_controller.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class UsersController < ApplicationController
|
||||
end
|
2
app/helpers/users_helper.rb
Normal file
2
app/helpers/users_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module UsersHelper
|
||||
end
|
6
app/models/user.rb
Normal file
6
app/models/user.rb
Normal file
@ -0,0 +1,6 @@
|
||||
class User < ApplicationRecord
|
||||
has_secure_password
|
||||
|
||||
validates :name, presence: true
|
||||
validates :email, presence: true, format: { with: /\S+@\S+/ }, uniqueness: { case_sensitive: false }
|
||||
end
|
@ -1,4 +1,5 @@
|
||||
Rails.application.routes.draw do
|
||||
resources :users
|
||||
resources :reviews
|
||||
root "movies#index"
|
||||
|
||||
|
11
db/migrate/20230926182250_create_users.rb
Normal file
11
db/migrate/20230926182250_create_users.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateUsers < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :users do |t|
|
||||
t.string :name
|
||||
t.string :email
|
||||
t.string :password_digest
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
10
db/schema.rb
generated
10
db/schema.rb
generated
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_09_26_165701) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_09_26_182250) do
|
||||
create_table "movies", force: :cascade do |t|
|
||||
t.string "title"
|
||||
t.string "rating"
|
||||
@ -34,5 +34,13 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_26_165701) do
|
||||
t.index ["movie_id"], name: "index_reviews_on_movie_id"
|
||||
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
|
||||
|
||||
add_foreign_key "reviews", "movies"
|
||||
end
|
||||
|
7
test/controllers/users_controller_test.rb
Normal file
7
test/controllers/users_controller_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
11
test/fixtures/users.yml
vendored
Normal file
11
test/fixtures/users.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
email: MyString
|
||||
password_digest: <%= BCrypt::Password.create("secret") %>
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
email: MyString
|
||||
password_digest: <%= BCrypt::Password.create("secret") %>
|
7
test/models/user_test.rb
Normal file
7
test/models/user_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class UserTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user