Complete Lesson 26

main
Simon Quigley 1 year ago
parent c3fbb70cff
commit 014c15fe4e

@ -34,7 +34,7 @@ gem "jbuilder"
# gem "kredis" # gem "kredis"
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] # 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 # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

@ -70,6 +70,7 @@ GEM
public_suffix (>= 2.0.2, < 6.0) public_suffix (>= 2.0.2, < 6.0)
autoprefixer-rails (10.4.15.0) autoprefixer-rails (10.4.15.0)
execjs (~> 2) execjs (~> 2)
bcrypt (3.1.19)
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.16.0) bootsnap (1.16.0)
msgpack (~> 1.2) msgpack (~> 1.2)
@ -225,6 +226,7 @@ PLATFORMS
x86_64-linux x86_64-linux
DEPENDENCIES DEPENDENCIES
bcrypt
bootsnap bootsnap
bootstrap bootstrap
capybara capybara

@ -0,0 +1,2 @@
class UsersController < ApplicationController
end

@ -0,0 +1,2 @@
module UsersHelper
end

@ -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 Rails.application.routes.draw do
resources :users
resources :reviews resources :reviews
root "movies#index" root "movies#index"

@ -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,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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| create_table "movies", force: :cascade do |t|
t.string "title" t.string "title"
t.string "rating" 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" t.index ["movie_id"], name: "index_reviews_on_movie_id"
end 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" add_foreign_key "reviews", "movies"
end end

@ -0,0 +1,7 @@
require "test_helper"
class UsersControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end

@ -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") %>

@ -0,0 +1,7 @@
require "test_helper"
class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Loading…
Cancel
Save