質問編集履歴
1
コードの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,12 +9,14 @@
|
|
9
9
|
<div class="container">
|
10
10
|
<h1 class="users-heading">ユーザー一覧</h1>
|
11
11
|
<!-- 以下の<% %>を使ってeach文を追加してください -->
|
12
|
+
<% @users.each do |user| %>
|
12
13
|
<div class="users-index-item">
|
13
14
|
<div class="user-right">
|
14
15
|
<!-- 以下の<%= %>を使ってユーザー名を表示してください -->
|
15
16
|
<%= link_to(current_user.username, "/users/#{user.id}") %>
|
16
17
|
</div>
|
17
18
|
</div>
|
19
|
+
<% end %>
|
18
20
|
<!-- 以下の<% %>を使ってeach文のendを追加してください -->
|
19
21
|
</div>
|
20
22
|
</div>
|
@@ -33,4 +35,31 @@
|
|
33
35
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
34
36
|
end
|
35
37
|
|
38
|
+
```
|
39
|
+
```ruby
|
40
|
+
//uesr.rb
|
41
|
+
class User < ApplicationRecord
|
42
|
+
# Include default devise modules. Others available are:
|
43
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
44
|
+
devise :database_authenticatable, :registerable,
|
45
|
+
:recoverable, :rememberable, :validatable
|
46
|
+
# nameカラムに関するバリデーションを作成してください
|
47
|
+
#validates :name, {presence: true}
|
48
|
+
|
49
|
+
# emailカラムに関するバリデーションを作成してください
|
50
|
+
#validates :email, {presence: true, uniqueness: true}
|
51
|
+
|
52
|
+
def username
|
53
|
+
return self.email.split('@')[0].capitalize
|
54
|
+
end
|
55
|
+
|
56
|
+
def index
|
57
|
+
@users = User.all
|
58
|
+
end
|
59
|
+
|
60
|
+
def show
|
61
|
+
@user = User.find_by(id: params[:id])
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
36
65
|
```
|