Skip to content

Commit 1a308eb

Browse files
committed
2.3.3 モデルの関連づけ
1 parent 2fe064e commit 1a308eb

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

app/models/micropost.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class Micropost < ActiveRecord::Base
2+
belongs_to :user
23
validates :content, length: { maximum: 140 }
34
end

app/models/user.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class User < ActiveRecord::Base
2+
has_many :microposts
23
end

0 commit comments

Comments
 (0)