質問編集履歴
7
マークダウン 使いにくい
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,7 +78,7 @@
|
|
78
78
|
|
79
79
|
下記のようなエラーが画面に表示されます。
|
80
80
|
|
81
|
-
|
81
|
+
```ruby
|
82
82
|
|
83
83
|
unknown attribute 'order' for Micropost.
|
84
84
|
|
@@ -114,9 +114,7 @@
|
|
114
114
|
|
115
115
|
Parameters:
|
116
116
|
|
117
|
-
|
117
|
+
```
|
118
|
-
|
119
|
-
|
120
118
|
|
121
119
|
<開発環境>
|
122
120
|
|
6
マークダウン 使いにくい
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
(app/models/micropost.rb)
|
40
40
|
|
41
|
-
|
41
|
+
```ruby
|
42
42
|
|
43
43
|
'class Micropost < ActiveRecord::Base
|
44
44
|
|
@@ -70,9 +70,9 @@
|
|
70
70
|
|
71
71
|
end
|
72
72
|
|
73
|
-
end
|
73
|
+
end
|
74
74
|
|
75
|
-
|
75
|
+
```
|
76
76
|
|
77
77
|
14章の最後まで通してみて、サーバーを起動させているのですが、
|
78
78
|
|
5
マークダウン 使いにくい
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
'''lang-ruby
|
42
42
|
|
43
|
-
class Micropost < ActiveRecord::Base
|
43
|
+
'class Micropost < ActiveRecord::Base
|
44
44
|
|
45
45
|
attr_accessor :content
|
46
46
|
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
end
|
72
72
|
|
73
|
-
end
|
73
|
+
end'
|
74
74
|
|
75
75
|
'''
|
76
76
|
|
4
マークダウンの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
(app/models/micropost.rb)
|
40
40
|
|
41
|
-
'''
|
41
|
+
'''lang-ruby
|
42
42
|
|
43
43
|
class Micropost < ActiveRecord::Base
|
44
44
|
|
@@ -78,7 +78,7 @@
|
|
78
78
|
|
79
79
|
下記のようなエラーが画面に表示されます。
|
80
80
|
|
81
|
-
'''
|
81
|
+
'''lang-Ruby
|
82
82
|
|
83
83
|
unknown attribute 'order' for Micropost.
|
84
84
|
|
3
マークダウンの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,6 +38,8 @@
|
|
38
38
|
|
39
39
|
(app/models/micropost.rb)
|
40
40
|
|
41
|
+
'''
|
42
|
+
|
41
43
|
class Micropost < ActiveRecord::Base
|
42
44
|
|
43
45
|
attr_accessor :content
|
@@ -70,13 +72,13 @@
|
|
70
72
|
|
71
73
|
end
|
72
74
|
|
73
|
-
|
75
|
+
'''
|
74
76
|
|
75
77
|
14章の最後まで通してみて、サーバーを起動させているのですが、
|
76
78
|
|
77
79
|
下記のようなエラーが画面に表示されます。
|
78
80
|
|
79
|
-
|
81
|
+
'''
|
80
82
|
|
81
83
|
unknown attribute 'order' for Micropost.
|
82
84
|
|
@@ -112,7 +114,7 @@
|
|
112
114
|
|
113
115
|
Parameters:
|
114
116
|
|
115
|
-
|
117
|
+
'''
|
116
118
|
|
117
119
|
|
118
120
|
|
2
初心者マークをつける
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -35,6 +35,42 @@
|
|
35
35
|
(https://railstutorial.jp/chapters/following_users?version=5.1#fig-live_status_feed)
|
36
36
|
|
37
37
|
を参考に学習しています。
|
38
|
+
|
39
|
+
(app/models/micropost.rb)
|
40
|
+
|
41
|
+
class Micropost < ActiveRecord::Base
|
42
|
+
|
43
|
+
attr_accessor :content
|
44
|
+
|
45
|
+
belongs_to :user
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
validates :user_id, presence: true
|
50
|
+
|
51
|
+
validates :content, presence: true, length: { maximum: 140 }
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
default_scope {where order: 'microposts.created_at DESC'}
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
def self.from_users_followed_by(user)
|
60
|
+
|
61
|
+
followed_user_ids = "SELECT followed_id FROM relationships
|
62
|
+
|
63
|
+
WHERE follower_id = :user_id"
|
64
|
+
|
65
|
+
where("user_id IN (#{followed_user_ids}) OR user_id = :user_id",
|
66
|
+
|
67
|
+
user_id: user.id)
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
38
74
|
|
39
75
|
14章の最後まで通してみて、サーバーを起動させているのですが、
|
40
76
|
|