質問編集履歴
1
login_check.html.erbとhello_controller.rbを追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,6 +44,82 @@
|
|
44
44
|
|
45
45
|
```
|
46
46
|
|
47
|
+
```ruby
|
48
|
+
|
49
|
+
#hello_controller.rb
|
50
|
+
|
51
|
+
class HelloController < ApplicationController
|
52
|
+
|
53
|
+
layout 'application'
|
54
|
+
|
55
|
+
before_action :authenticate_account!, only: :login_check
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
def index
|
60
|
+
|
61
|
+
@msg = 'this is sample page.'
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
def login_check
|
68
|
+
|
69
|
+
@account = current_account
|
70
|
+
|
71
|
+
@msg = 'account created at: ' + @account.created_at.to_s
|
72
|
+
|
73
|
+
@id = [1,2,3]
|
74
|
+
|
75
|
+
@url = ["/hello/search_category/","/hello/category/","/notes/"]
|
76
|
+
|
77
|
+
@category = ["Shopping#search","Shopping#category","Shopping#note"]
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
・・・
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
|
87
|
+
#login_check.html.erb
|
88
|
+
|
89
|
+
<h1 class="display-4 text-primary"><%= "Hello#" + @account.email %></h1>
|
90
|
+
|
91
|
+
<p><%= @msg %></p>
|
92
|
+
|
93
|
+
<p><a href="/hello/login_check/">Home</a></p>
|
94
|
+
|
95
|
+
<table class="table">
|
96
|
+
|
97
|
+
<tr>
|
98
|
+
|
99
|
+
<th>Id</th><th >category</th>
|
100
|
+
|
101
|
+
</tr>
|
102
|
+
|
103
|
+
<% @id.zip(@url,@category) do |id,url,category| %>
|
104
|
+
|
105
|
+
<tr>
|
106
|
+
|
107
|
+
<td><%= id %></td>
|
108
|
+
|
109
|
+
<td><a href=<%= url %>><%= category %></a></td>
|
110
|
+
|
111
|
+
</tr>
|
112
|
+
|
113
|
+
<% end %>
|
114
|
+
|
115
|
+
</table>
|
116
|
+
|
117
|
+
<div><%=link_to '<<go back'.html_safe,{action:'index'} %></div>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
```
|
122
|
+
|
47
123
|
|
48
124
|
|
49
125
|
### 試したこと
|