質問編集履歴
5
schema.rbの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -108,7 +108,94 @@
|
|
108
108
|
```
|
109
109
|
|
110
110
|
|
111
|
+
**schema.rb**
|
111
112
|
|
113
|
+
```
|
114
|
+
# This file is auto-generated from the current state of the database. Instead
|
115
|
+
# of editing this file, please use the migrations feature of Active Record to
|
116
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
117
|
+
#
|
118
|
+
# This file is the source Rails uses to define your schema when running `rails
|
119
|
+
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
|
120
|
+
# be faster and is potentially less error prone than running all of your
|
121
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
122
|
+
# migrations use external dependencies or application code.
|
123
|
+
#
|
124
|
+
# It's strongly recommended that you check this file into your version control system.
|
125
|
+
|
126
|
+
ActiveRecord::Schema.define(version: 2020_10_23_085817) do
|
127
|
+
|
128
|
+
create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
129
|
+
t.string "name", null: false
|
130
|
+
t.string "record_type", null: false
|
131
|
+
t.bigint "record_id", null: false
|
132
|
+
t.bigint "blob_id", null: false
|
133
|
+
t.datetime "created_at", null: false
|
134
|
+
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
|
135
|
+
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
|
136
|
+
end
|
137
|
+
|
138
|
+
create_table "active_storage_blobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
139
|
+
t.string "key", null: false
|
140
|
+
t.string "filename", null: false
|
141
|
+
t.string "content_type"
|
142
|
+
t.text "metadata"
|
143
|
+
t.bigint "byte_size", null: false
|
144
|
+
t.string "checksum", null: false
|
145
|
+
t.datetime "created_at", null: false
|
146
|
+
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
|
147
|
+
end
|
148
|
+
|
149
|
+
create_table "comments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
150
|
+
t.integer "user_id", null: false
|
151
|
+
t.integer "photo_id", null: false
|
152
|
+
t.text "text"
|
153
|
+
t.datetime "created_at", precision: 6, null: false
|
154
|
+
t.datetime "updated_at", precision: 6, null: false
|
155
|
+
end
|
156
|
+
|
157
|
+
create_table "favorites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
158
|
+
t.integer "user_id", null: false
|
159
|
+
t.integer "photo_id", null: false
|
160
|
+
t.datetime "created_at", precision: 6, null: false
|
161
|
+
t.datetime "updated_at", precision: 6, null: false
|
162
|
+
end
|
163
|
+
|
164
|
+
create_table "photos", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
165
|
+
t.text "explanation", null: false
|
166
|
+
t.string "title", null: false
|
167
|
+
t.integer "user_id", null: false
|
168
|
+
t.datetime "created_at", precision: 6, null: false
|
169
|
+
t.datetime "updated_at", precision: 6, null: false
|
170
|
+
end
|
171
|
+
|
172
|
+
create_table "relationships", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
173
|
+
t.integer "following_id", null: false
|
174
|
+
t.integer "follower_id", null: false
|
175
|
+
t.datetime "created_at", precision: 6, null: false
|
176
|
+
t.datetime "updated_at", precision: 6, null: false
|
177
|
+
t.index ["follower_id", "following_id"], name: "index_relationships_on_follower_id_and_following_id", unique: true
|
178
|
+
end
|
179
|
+
|
180
|
+
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
181
|
+
t.string "nickname", null: false
|
182
|
+
t.string "email", default: "", null: false
|
183
|
+
t.string "encrypted_password", default: "", null: false
|
184
|
+
t.text "profile"
|
185
|
+
t.string "reset_password_token"
|
186
|
+
t.datetime "reset_password_sent_at"
|
187
|
+
t.datetime "remember_created_at"
|
188
|
+
t.datetime "created_at", precision: 6, null: false
|
189
|
+
t.datetime "updated_at", precision: 6, null: false
|
190
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
191
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
192
|
+
end
|
193
|
+
|
194
|
+
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
195
|
+
end
|
196
|
+
```
|
197
|
+
|
198
|
+
|
112
199
|
このようなコードになっております
|
113
200
|
**皆様のお力をお貸しください!
|
114
201
|
よろしくお願いいたします!**
|
4
コードを使いしました
title
CHANGED
File without changes
|
body
CHANGED
@@ -68,7 +68,7 @@
|
|
68
68
|
end
|
69
69
|
```
|
70
70
|
|
71
|
-
##追加コード
|
71
|
+
##皆様のご指摘で追加したコード達
|
72
72
|
```
|
73
73
|
**registrations_controller.rb**
|
74
74
|
def update
|
@@ -83,8 +83,32 @@
|
|
83
83
|
```
|
84
84
|
自己紹介文は@userに入っています…しかし保存はできません…
|
85
85
|
|
86
|
+
**binding.pryにて@user.errors.messagesを追加**
|
87
|
+
```
|
88
|
+
[1] pry(#<Users::RegistrationsController>)> @user.update
|
89
|
+
ArgumentError: wrong number of arguments (given 0, expected 1)
|
90
|
+
from /Users/eleaco/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/persistence.rb:616:in `update'
|
91
|
+
[2] pry(#<Users::RegistrationsController>)> @user.errors.messages
|
92
|
+
=> {:password=>["can't be blank", "is invalid"], :current_password=>["can't be blank"], :profile=>[]}#profileに記述しましたが空のようです
|
93
|
+
[3] pry(#<Users::RegistrationsController>)>
|
94
|
+
```
|
86
95
|
|
96
|
+
**user.rb**
|
97
|
+
```
|
98
|
+
devise :database_authenticatable, :registerable,
|
99
|
+
:recoverable, :rememberable, :validatable
|
87
100
|
|
101
|
+
with_options presence: true do |i|
|
102
|
+
i.validates :nickname
|
103
|
+
i.validates :email
|
104
|
+
i.validates :password
|
105
|
+
i.validates :encrypted_password
|
106
|
+
#profileを記述していない!!ここでしょうか…?
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
|
111
|
+
|
88
112
|
このようなコードになっております
|
89
113
|
**皆様のお力をお貸しください!
|
90
114
|
よろしくお願いいたします!**
|
3
追加でコードを記述しました!
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
```
|
7
7
|
**registrations_controller.rb**
|
8
8
|
def update
|
9
|
-
@user.update(account_update_params)
|
10
9
|
super
|
11
10
|
binding.pry
|
12
11
|
end
|
@@ -44,7 +43,8 @@
|
|
44
43
|
|
45
44
|
before_action :configure_account_update_parameters, only: [:update]
|
46
45
|
def update
|
47
|
-
@user.update(account_update_params)
|
46
|
+
#@user.update(account_update_params)ここ消しました理由はbefore_actionで
|
47
|
+
#configure_account_update_parametersメソッドを呼び出しているからです
|
48
48
|
end
|
49
49
|
|
50
50
|
protected
|
@@ -68,6 +68,23 @@
|
|
68
68
|
end
|
69
69
|
```
|
70
70
|
|
71
|
+
##追加コード
|
72
|
+
```
|
73
|
+
**registrations_controller.rb**
|
74
|
+
def update
|
75
|
+
super
|
76
|
+
binding.pry
|
77
|
+
end
|
78
|
+
```
|
79
|
+
**binding.pryで中に何が入っているか確認します**
|
80
|
+
```
|
81
|
+
[2] pry(#<Users::RegistrationsController>)> @user
|
82
|
+
=> #<User id: 2, nickname: "gest", email: "gest@gest", profile: "これは自己紹介です", created_at: "2020-11-01 00:55:52", updated_at: "2020-11-01 00:55:52">
|
83
|
+
```
|
84
|
+
自己紹介文は@userに入っています…しかし保存はできません…
|
85
|
+
|
86
|
+
|
87
|
+
|
71
88
|
このようなコードになっております
|
72
89
|
**皆様のお力をお貸しください!
|
73
90
|
よろしくお願いいたします!**
|
2
エラー文の出力
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,8 +1,19 @@
|
|
1
1
|
Railsにてdeviseを使用したユーザー情報のアップデートを実行中エラーが出ており躓いています…
|
2
2
|
|
3
3
|
##エラー文
|
4
|
+
refistrations_controller.rbのupdateにbinding.pryでエラーを出力しております
|
4
5
|
|
5
6
|
```
|
7
|
+
**registrations_controller.rb**
|
8
|
+
def update
|
9
|
+
@user.update(account_update_params)
|
10
|
+
super
|
11
|
+
binding.pry
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
ターミナル上でエラー文を確認
|
16
|
+
```
|
6
17
|
[2] pry(#<Users::RegistrationsController>)> @user.update
|
7
18
|
ArgumentError: wrong number of arguments (given 0, expected 1)
|
8
19
|
from /Users/eleaco/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/persistence.rb:616:in `update'
|
1
エラー文の追加を行いました
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
```
|
6
6
|
[2] pry(#<Users::RegistrationsController>)> @user.update
|
7
7
|
ArgumentError: wrong number of arguments (given 0, expected 1)
|
8
|
+
from /Users/eleaco/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.4/lib/active_record/persistence.rb:616:in `update'
|
8
9
|
```
|
9
10
|
|
10
11
|
よくみる引数が一つ必要だが足りないと言われています…
|