質問するログイン新規登録

質問編集履歴

1

models/user.rbを追加しました。

2018/08/23 10:03

投稿

akiakiakirin
akiakiakirin

スコア13

title CHANGED
File without changes
body CHANGED
@@ -242,4 +242,22 @@
242
242
  <p>ヤッホイ</p>
243
243
  <% end %>
244
244
 
245
+ ```
246
+ ### models/user.rb
247
+ ```
248
+ class User < ApplicationRecord
249
+ # Include default devise modules. Others available are:
250
+ # :confirmable, :lockable, :timeoutable and :omniauthable
251
+ devise :database_authenticatable, :registerable,
252
+ :recoverable, :rememberable, :trackable, :validatable
253
+
254
+ has_many :posts
255
+
256
+ def posts
257
+ return Post.where(user_id: self.id)
258
+ end
259
+
260
+
261
+ end
262
+
245
263
  ```