質問編集履歴
4
初心者
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
3
データの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,6 +48,32 @@
|
|
48
48
|
|
49
49
|
undefined method 'password' in 'user' factory
|
50
50
|
|
51
|
+
# ./spec/factories/users.rb:5:in `block (2 levels) in <main>'
|
52
|
+
|
53
|
+
# ./spec/factories/users.rb:2:in `block in <main>'
|
54
|
+
|
55
|
+
# ./spec/factories/users.rb:1:in `<main>'
|
56
|
+
|
57
|
+
# ./config/environment.rb:5:in `<top (required)>'
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
# ./spec/rails_helper.rb:4:in `require'
|
62
|
+
|
63
|
+
# ./spec/rails_helper.rb:4:in `<top (required)>'
|
64
|
+
|
65
|
+
# ./spec/models/user_spec.rb:1:in `require'
|
66
|
+
|
67
|
+
# ./spec/models/user_spec.rb:1:in `<top (required)>'
|
68
|
+
|
69
|
+
No examples found.
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
Finished in 0.00064 seconds (files took 2.23 seconds to load)
|
74
|
+
|
75
|
+
0 examples, 0 failures, 1 error occurred outside of examples
|
76
|
+
|
51
77
|
```
|
52
78
|
|
53
79
|
|
2
データの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -93,3 +93,91 @@
|
|
93
93
|
end
|
94
94
|
|
95
95
|
```
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
|
99
|
+
# app/models/user.rb
|
100
|
+
|
101
|
+
class User < ApplicationRecord
|
102
|
+
|
103
|
+
has_many :posts, dependent: :destroy
|
104
|
+
|
105
|
+
has_many :likes
|
106
|
+
|
107
|
+
has_many :comments
|
108
|
+
|
109
|
+
# Include default devise modules. Others available are:
|
110
|
+
|
111
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
112
|
+
|
113
|
+
devise :database_authenticatable, :registerable,
|
114
|
+
|
115
|
+
:recoverable, :rememberable, :validatable
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
validates :name, presence: true, length: { maximum: 50 }
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
def update_without_current_password(params, *options)
|
124
|
+
|
125
|
+
params.delete(:current_password)
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
if params[:password].blank? && params[:password_confirmation].blank?
|
130
|
+
|
131
|
+
params.delete(:password)
|
132
|
+
|
133
|
+
params.delete(:password_confirmation)
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
result = update_attributes(params, *options)
|
140
|
+
|
141
|
+
clean_up_passwords
|
142
|
+
|
143
|
+
result
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
|
153
|
+
# db/schema.rb
|
154
|
+
|
155
|
+
create_table "users", force: :cascade do |t|
|
156
|
+
|
157
|
+
t.string "email", default: "", null: false
|
158
|
+
|
159
|
+
t.string "encrypted_password", default: "", null: false
|
160
|
+
|
161
|
+
t.string "reset_password_token"
|
162
|
+
|
163
|
+
t.datetime "reset_password_sent_at"
|
164
|
+
|
165
|
+
t.datetime "remember_created_at"
|
166
|
+
|
167
|
+
t.datetime "created_at", null: false
|
168
|
+
|
169
|
+
t.datetime "updated_at", null: false
|
170
|
+
|
171
|
+
t.string "name", default: "", null: false
|
172
|
+
|
173
|
+
t.string "profile_photo"
|
174
|
+
|
175
|
+
t.string "website"
|
176
|
+
|
177
|
+
t.text "bio"
|
178
|
+
|
179
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
180
|
+
|
181
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
182
|
+
|
183
|
+
```
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
(エラーの詳細や関連ファイルは下記にあります。)
|
10
10
|
|
11
|
-
エラー内容でググったり調べてみましたが、解決策
|
11
|
+
エラー内容でググったり調べてみましたが、解決策や解決への手がかりが見つけられず、お手数ですがご教示頂けますと幸いです。
|
12
12
|
|
13
13
|
どうぞよろしくお願い致します。
|
14
14
|
|