Skip to content

Commit

Permalink
ルーティングの修正。ログアウトが機能しなかったので、link_toからbutton_toに修正。
Browse files Browse the repository at this point in the history
  • Loading branch information
ishi720 committed Jun 9, 2024
1 parent e64b551 commit 17a2b38
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
7 changes: 7 additions & 0 deletions app/views/calendar/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<h1 class="ui header">キャラクターカレンダー</h1>

<% if user_signed_in? %>
<%= button_to 'Logout', destroy_user_session_path, method: :delete, class: "ui button" %>
<% else %>
<%= link_to 'Login', new_user_session_path, class: "ui button" %>
<% end %>


<div class="ui buttons" style="padding-bottom: 10px;">
<%= link_to calendar_index_path, class: "ui button primary" do %>
<i class="calendar icon"></i> カレンダー
Expand Down
7 changes: 7 additions & 0 deletions app/views/characters/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<h1 class="ui header">キャラクター一覧</h1>

<% if user_signed_in? %>
<%= button_to 'Logout', destroy_user_session_path, method: :delete, class: "ui button" %>
<% else %>
<%= link_to 'Login', new_user_session_path, class: "ui button" %>
<% end %>


<div class="ui buttons" style="padding-bottom: 10px;">
<%= link_to calendar_index_path, class: "ui button" do %>
<i class="calendar icon"></i> カレンダー
Expand Down
8 changes: 3 additions & 5 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<h1>Home#index</h1>
<p>Find me in app/views/home/index.html.erb</p>

<% if user_signed_in? %>
<h2>Welcome, <%= current_user.email %></h2>
<%= link_to 'Logout', destroy_user_session_path, method: :delete %>
<h2>ログイン中</h2>
<%= button_to 'Logout', destroy_user_session_path, method: :delete %>
<% else %>
<h2>未ログイン</h2>
<%= link_to 'Login', new_user_session_path %>
<% end %>
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rails.application.routes.draw do
get 'home/index'
# get 'home/index'
devise_for :users
root to: "home#index"
root to: "calendar#index"

# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

Expand Down

0 comments on commit 17a2b38

Please sign in to comment.