質問編集履歴

1

コードの追記

2018/11/19 03:43

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -20,6 +20,8 @@
20
20
 
21
21
  <!-- 以下の<% %>を使ってeach文を追加してください -->
22
22
 
23
+ <% @users.each do |user| %>
24
+
23
25
  <div class="users-index-item">
24
26
 
25
27
  <div class="user-right">
@@ -31,6 +33,8 @@
31
33
  </div>
32
34
 
33
35
  </div>
36
+
37
+ <% end %>
34
38
 
35
39
  <!-- 以下の<% %>を使ってeach文のendを追加してください -->
36
40
 
@@ -69,3 +73,57 @@
69
73
 
70
74
 
71
75
  ```
76
+
77
+ ```ruby
78
+
79
+ //uesr.rb
80
+
81
+ class User < ApplicationRecord
82
+
83
+ # Include default devise modules. Others available are:
84
+
85
+ # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
86
+
87
+ devise :database_authenticatable, :registerable,
88
+
89
+ :recoverable, :rememberable, :validatable
90
+
91
+ # nameカラムに関するバリデーションを作成してください
92
+
93
+ #validates :name, {presence: true}
94
+
95
+
96
+
97
+ # emailカラムに関するバリデーションを作成してください
98
+
99
+ #validates :email, {presence: true, uniqueness: true}
100
+
101
+
102
+
103
+ def username
104
+
105
+ return self.email.split('@')[0].capitalize
106
+
107
+ end
108
+
109
+
110
+
111
+ def index
112
+
113
+ @users = User.all
114
+
115
+ end
116
+
117
+
118
+
119
+ def show
120
+
121
+ @user = User.find_by(id: params[:id])
122
+
123
+ end
124
+
125
+
126
+
127
+ end
128
+
129
+ ```