質問編集履歴
2
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -97,10 +97,8 @@
|
|
97
97
|
|
98
98
|
```
|
99
99
|
|
100
|
-
```ruby
|
101
100
|
|
102
101
|
|
103
|
-
|
104
102
|
### 試したこと
|
105
103
|
|
106
104
|
@user = User.find(current_user.id)のあとにbinding.pryを入れて確認してみたところ@userにはしっかりとuserの情報が入っていました
|
@@ -168,7 +166,7 @@
|
|
168
166
|
こちらがbinding.pryをして@user.errors.full_messagesを記述した際のものです
|
169
167
|
|
170
168
|
こちらが@user.update!にした時のエラー文です
|
171
|
-
https://
|
169
|
+
https://i.gyazo.com/2cc0f56667a78a3e3f9f4bcc9bd292a9.png
|
172
170
|
|
173
171
|
自分にはこの解決方法がわかりません。
|
174
172
|
お力添えをしていただけるとありがたいです。
|
1
【1】 app/models/user.rb のコード 【2】 db/schema.rb の users 部分 【3】 binding.pry で止めた状態で、「 @user.errors.ful
title
CHANGED
File without changes
|
body
CHANGED
@@ -42,6 +42,65 @@
|
|
42
42
|
|
43
43
|
```
|
44
44
|
|
45
|
+
```ruby
|
46
|
+
|
47
|
+
class User < ApplicationRecord
|
48
|
+
has_one_attached :image
|
49
|
+
|
50
|
+
devise :database_authenticatable, :registerable,
|
51
|
+
:recoverable, :rememberable, :validatable
|
52
|
+
|
53
|
+
validates :nickname, :birthday, presence: true
|
54
|
+
|
55
|
+
validates :password, format: { with: /\A(?=.*?[a-z])(?=.*?[\d])[a-z\d]+\z/i}
|
56
|
+
|
57
|
+
with_options presence: true, format: { with: /\A[ぁ-んァ-ヶ一-龥々]+\z/ } do
|
58
|
+
validates :first_name
|
59
|
+
validates :last_name
|
60
|
+
end
|
61
|
+
|
62
|
+
with_options presence: true, format: {with:/\A[ァ-ヶ]+\z/} do
|
63
|
+
validates :first_name_katakana
|
64
|
+
validates :last_name_katakana
|
65
|
+
end
|
66
|
+
|
67
|
+
has_many :celebs, through: :rooms
|
68
|
+
has_many :rooms, dependent: :destroy
|
69
|
+
has_many :messages, dependent: :destroy
|
70
|
+
has_one :card, dependent: :destroy
|
71
|
+
has_many :likes, dependent: :destroy
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
79
|
+
t.string "email", default: "", null: false
|
80
|
+
t.string "encrypted_password", default: "", null: false
|
81
|
+
t.string "nickname", null: false
|
82
|
+
t.string "last_name", null: false
|
83
|
+
t.string "first_name", null: false
|
84
|
+
t.string "first_name_katakana", null: false
|
85
|
+
t.string "last_name_katakana", null: false
|
86
|
+
t.date "birthday", null: false
|
87
|
+
t.boolean "order", default: false
|
88
|
+
t.string "reset_password_token"
|
89
|
+
t.datetime "reset_password_sent_at"
|
90
|
+
t.datetime "remember_created_at"
|
91
|
+
t.datetime "created_at", precision: 6, null: false
|
92
|
+
t.datetime "updated_at", precision: 6, null: false
|
93
|
+
t.boolean "admin", default: false
|
94
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
95
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
96
|
+
end
|
97
|
+
|
98
|
+
```
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
|
102
|
+
|
103
|
+
|
45
104
|
### 試したこと
|
46
105
|
|
47
106
|
@user = User.find(current_user.id)のあとにbinding.pryを入れて確認してみたところ@userにはしっかりとuserの情報が入っていました
|
@@ -82,6 +141,35 @@
|
|
82
141
|
こちらがbinding.pryの結果です。
|
83
142
|
1回目のpryで@userを入力するとorderはfalseで返ってきました。
|
84
143
|
しかし2回目でupdateアクションを行うとfalseと返って来るのですが4回目ではorderがtrueとなっています。
|
144
|
+
|
145
|
+
3: def create
|
146
|
+
4: redirect_to new_card_path and return unless current_user.card.present?
|
147
|
+
5:
|
148
|
+
6: @price = Price.find(params[:price_id])
|
149
|
+
7:
|
150
|
+
8: Payjp.api_key = ENV["PAYJP_SECRET_KEY"]
|
151
|
+
9: customer_token = current_user.card.customer_token
|
152
|
+
10: Payjp::Charge.create(
|
153
|
+
11: amount: @price.content,
|
154
|
+
12: customer: customer_token,
|
155
|
+
13: currency: 'jpy'
|
156
|
+
14: )
|
157
|
+
15:
|
158
|
+
16: @room = Room.find(params[:room_id])
|
159
|
+
17: @order = Order.create(price_id: @price.id, room_id: @room.id)
|
160
|
+
18: @message = Message.create(room_id: @room.id, user_id: @room.user.id, content:"#{current_user.nickname}さんから#{@price.content}円が送られました!!", order: true)
|
161
|
+
19: @user = User.find(current_user.id)
|
162
|
+
20: @user.update(order: true)
|
163
|
+
=> 21: binding.pry
|
164
|
+
22: ActionCable.server.broadcast 'stanp_channel', content: @message
|
165
|
+
[1] pry(#<OrdersController>)> @user.errors.full_messages
|
166
|
+
=> ["パスワードは不正な値です"]
|
167
|
+
|
168
|
+
こちらがbinding.pryをして@user.errors.full_messagesを記述した際のものです
|
169
|
+
|
170
|
+
こちらが@user.update!にした時のエラー文です
|
171
|
+
https://gyazo.com/2cc0f56667a78a3e3f9f4bcc9bd292a9https://gyazo.com/2cc0f56667a78a3e3f9f4bcc9bd292a9
|
172
|
+
|
85
173
|
自分にはこの解決方法がわかりません。
|
86
174
|
お力添えをしていただけるとありがたいです。
|
87
175
|
### 補足情報(FW/ツールのバージョンなど)
|