質問編集履歴

2

追記

2019/06/11 08:26

投稿

tomtom1
tomtom1

スコア168

test CHANGED
File without changes
test CHANGED
@@ -60,6 +60,30 @@
60
60
 
61
61
  ```
62
62
 
63
+ ```controller
64
+
65
+ def update
66
+
67
+ @user = User.find_by(id: params[:id])
68
+
69
+ @user.name = params[:name]
70
+
71
+ @user.birthday = params[:birthday]
72
+
73
+ #end
74
+
75
+ if @user.save
76
+
77
+ redirect_to("/users/#{@user.id}")
78
+
79
+ else
80
+
81
+ render("users/edit")
82
+
83
+ end
84
+
85
+ ```
86
+
63
87
  ```schema
64
88
 
65
89
  create_table "users", force: :cascade do |t|

1

追記

2019/06/11 08:26

投稿

tomtom1
tomtom1

スコア168

test CHANGED
File without changes
test CHANGED
@@ -4,9 +4,7 @@
4
4
 
5
5
  Viewにdate_selectは現れるのですが、
6
6
 
7
- 始まりが2014年から2024年の10年間しか選択できません。
7
+ 始まりが2014年から2024年の10年間しか選択できません。(月と日にち正常です)
8
-
9
- (月は1-12月、日は1-31日の選択があり正常です)
10
8
 
11
9
 
12
10
 
@@ -41,3 +39,35 @@
41
39
  ```
42
40
 
43
41
  Optionの記述方法に誤りがあるのでしょうか。
42
+
43
+
44
+
45
+ ### 追記
46
+
47
+ また、とりあえず2019年6月11日の日付で保存してみたところ、エラーが出てしましました。
48
+
49
+ ```Error
50
+
51
+ TypeError (can't cast ActionController::Parameters):
52
+
53
+ ```
54
+
55
+ ```Parameters
56
+
57
+ "name"=>"太郎",
58
+
59
+ "birthday"=>{"{:use_month_numbers=>true}(1i)"=>"2019", "{:use_month_numbers=>true}(2i)"=>"6", "{:use_month_numbers=>true}(3i)"=>"11"},
60
+
61
+ ```
62
+
63
+ ```schema
64
+
65
+ create_table "users", force: :cascade do |t|
66
+
67
+ t.string "name"
68
+
69
+ t.date "birthday"
70
+
71
+ end
72
+
73
+ ```