質問編集履歴

2

ファイルを追加しました

2020/06/07 15:49

投稿

mayok
mayok

スコア12

test CHANGED
@@ -1 +1 @@
1
- rails db:migrate:resetができない
1
+ rails db:migrate:resetで引数エラー出る
test CHANGED
@@ -124,6 +124,90 @@
124
124
 
125
125
 
126
126
 
127
+ ```
128
+
129
+ (user.rb)
130
+
131
+ class User < ApplicationRecord
132
+
133
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :omniauthable
134
+
135
+
136
+
137
+ has_many :microposts, dependent: :destroy
138
+
139
+ has_many :likes, dependent: :destroy
140
+
141
+ has_many :liked_posts, through: :likes, source: :micropost
142
+
143
+ has_many :bookmarks, dependent: :destroy
144
+
145
+ has_many :active_relationships, class_name: "Relationship",
146
+
147
+ foreign_key: "follower_id",
148
+
149
+ dependent: :destroy
150
+
151
+ has_many :passive_relationships, class_name: "Relationship",
152
+
153
+ foreign_key: "followed_id",
154
+
155
+ dependent: :destroy
156
+
157
+ has_many :following, through: :active_relationships, source: :followed
158
+
159
+ has_many :followers, through: :passive_relationships, source: :follower
160
+
161
+
162
+
163
+ validates :name, presence: true, length: { maximum: 50 }
164
+
165
+ validates :email, presence: true, length: { maximum: 255 }
166
+
167
+
168
+
169
+ def self.guest
170
+
171
+ find_or_create_by!(name: 'guest', email: 'guest@example.com') do |user|
172
+
173
+ user.password = SecureRandom.urlsafe_base64
174
+
175
+ user.confirmed_at = Time.zone.now
176
+
177
+ end
178
+
179
+ end
180
+
181
+
182
+
183
+ def follow(other_user)
184
+
185
+ following << other_user
186
+
187
+ end
188
+
189
+
190
+
191
+ def unfollow(other_user)
192
+
193
+ active_relationships.find_by(followed_id: other_user.id).destroy
194
+
195
+ end
196
+
197
+
198
+
199
+ def following?(other_user)
200
+
201
+ following.include?(other_user)
202
+
203
+ end
204
+
205
+ end
206
+
207
+ ```
208
+
209
+
210
+
127
211
  ### 試したこと
128
212
 
129
213
  記述したエラーが出力される前に

1

タイトルを変更

2020/06/07 15:49

投稿

mayok
mayok

スコア12

test CHANGED
@@ -1 +1 @@
1
- ArgumentError: wrong number of argumentsエラー解消できない
1
+ rails db:migrate:resetができない
test CHANGED
File without changes