Skip to content

Commit

Permalink
Fixed find_by_id
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenSanzas committed Oct 3, 2024
1 parent 0e99bee commit aa146ff
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# app/controllers/sessions_controller.rb
class SessionsController < ApplicationController
skip_before_action :require_login, only: [:omniauth]
skip_before_action :require_login, only: [ :omniauth ]

def logout
reset_session
Expand Down
2 changes: 1 addition & 1 deletion app/models/game.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Game < ApplicationRecord
validates :name, presence: true
end
end
1 change: 0 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
class User < ApplicationRecord
validates :email, presence: true, uniqueness: true
validates :uid, presence: true, uniqueness: true

end
5 changes: 5 additions & 0 deletions app/repositories/user_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ def self.find_by_uid(uid)
User.find_by(uid: uid)
end


def self.find_by_id(id)
User.find_by(id: id)
end

def self.create_user(uid:, email:, first_name:, last_name:)
User.create(uid: uid, email: email, first_name: first_name, last_name: last_name)
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/user_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def self.find_or_create_user(auth)
end

def self.find_user_by_id(id)
UserRepository.find_by(id)
UserRepository.find_by_id(id)
end
end
16 changes: 8 additions & 8 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# config/routes.rb
Rails.application.routes.draw do
get "sessions/logout"
get "sessions/omniauth"
get "users/show"
get "welcome/index"

root "welcome#index"

get "welcome/index", to: "welcome#index", as: "welcome"

get "/users/:id", to: "users#show", as: "user"
get "/logout", to: "sessions#logout", as: "logout"
get "/auth/google_oauth2/callback", to: "sessions#omniauth"

resources :games
root :to => redirect('/games')
resources :games

get "up" => "rails/health#show", as: :rails_health_check
get "up" => "rails/health#show", as: :rails_health_check

## stub paths to demo game landing page
get '/spellingbee/:id', to: 'games#demo_game', as: 'spellingbee'
get '/wordle/:id', to: 'games#demo_game', as: 'wordle'
get '/letterboxed/:id', to: 'games#demo_game', as: 'letterboxed'
get "/spellingbee/:id", to: "games#demo_game", as: "spellingbee"
get "/wordle/:id", to: "games#demo_game", as: "wordle"
get "/letterboxed/:id", to: "games#demo_game", as: "letterboxed"
end
14 changes: 7 additions & 7 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# end

initial_games = [
{:name => 'Spelling Bee', :game_path => 'spellingbee_path'},
{:name => 'Wordle', :game_path => 'wordle_path'},
{:name => 'Letter Boxed', :game_path => 'letterboxed_path'}
{ name: 'Spelling Bee', game_path: 'spellingbee_path' },
{ name: 'Wordle', game_path: 'wordle_path' },
{ name: 'Letter Boxed', game_path: 'letterboxed_path' }
]

initial_games.each do |game|
Expand Down

0 comments on commit aa146ff

Please sign in to comment.