Skip to content

Commit 6a3b7c4

Browse files
committed
added login/logout links, root path updated, puzzles controller added
1 parent c67507a commit 6a3b7c4

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class PuzzlesController < ApplicationController
2+
def index
3+
end
4+
end

app/helpers/puzzles_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module PuzzlesHelper
2+
end

app/views/puzzles/index.html.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<% if session[:user_token] %>
2+
<%= link_to 'Logout', session_path(1), data: { turbo_method: :delete } %>
3+
<% else %>
4+
<%= link_to 'Login with Google', '/auth/google_oauth2' %>
5+
<% end %>
6+
7+
<h1>Puzzles#index</h1>
8+
<p>Find me in app/views/puzzles/index.html.erb</p>

config/routes.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
Rails.application.routes.draw do
2+
resources :puzzles, only: [:index]
3+
resources :sessions, only: [:create, :destroy]
4+
25
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
36

47
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
@@ -12,5 +15,5 @@
1215
# get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
1316

1417
# Defines the root path route ("/")
15-
root "static#home"
18+
root "puzzles#index"
1619
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require "test_helper"
2+
3+
class PuzzlesControllerTest < ActionDispatch::IntegrationTest
4+
test "should get index" do
5+
get puzzles_index_url
6+
assert_response :success
7+
end
8+
end

0 commit comments

Comments
 (0)