質問編集履歴
2
試したことを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,189 +1,45 @@
|
|
1
1
|
レコードを複製したいのですが、パラメータを引っ張ってきてくれません。
|
2
2
|
|
3
|
-
param is missing or the value is emptyと出ます。
|
4
3
|
|
5
4
|
|
5
|
+
試したこと
|
6
6
|
|
7
7
|
```RUBY
|
8
8
|
|
9
9
|
def update_new
|
10
10
|
|
11
|
+
@retrieve_list = RetrieveList.new
|
12
|
+
|
11
|
-
@retrieve_list = RetrieveList.n
|
13
|
+
@retrieve_list = RetrieveList.find(params[:id]).dup
|
14
|
+
|
15
|
+
@retrieve_list.save
|
12
16
|
|
13
17
|
end
|
14
18
|
|
15
|
-
|
19
|
+
```
|
16
20
|
|
17
|
-
|
21
|
+
これを試しにSHOW画面に書いてみました。
|
18
22
|
|
19
|
-
|
23
|
+
```RUBY
|
20
24
|
|
21
|
-
|
25
|
+
def show
|
22
26
|
|
23
|
-
|
27
|
+
@retrieve_list = RetrieveList.new
|
24
28
|
|
25
|
-
|
29
|
+
@retrieve_list = RetrieveList.find(params[:id]).dup
|
26
30
|
|
27
|
-
|
31
|
+
@retrieve_list.save
|
28
32
|
|
29
|
-
|
33
|
+
end
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
これだとLink_toでIDを引っ張ってきてくれました。
|
38
|
+
|
39
|
+
しかしshow画面に行くたびに複製され、えらいことになります。
|
40
|
+
|
41
|
+
理想は前者でIDを引っ張ってきてくれれば成功しそうなのですが…。
|
30
42
|
|
31
43
|
|
32
44
|
|
33
|
-
# Never trust parameters from the scary internet, only allow the white list through.
|
34
|
-
|
35
|
-
def retrieve_list_params
|
36
|
-
|
37
|
-
params.require(:retrieve_list).permit(:id, :re_customer, :re_name, :re_title_no, :re_title, ・・・
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
```
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
登録画面
|
46
|
-
|
47
|
-
```RUBY
|
48
|
-
|
49
|
-
<%= form_for @retrieve_list, :html => { :class => 'form-horizontal' } do |f| %>
|
50
|
-
|
51
|
-
<% if @retrieve_list.errors.any? %>
|
52
|
-
|
53
|
-
<div id="error_explanation">
|
54
|
-
|
55
|
-
<h2><%= pluralize(@retrieve_list.errors.count, "error") %> prohibited this retrieve_list from being saved:</h2>
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
<ul>
|
60
|
-
|
61
|
-
<% @retrieve_list.errors.full_messages.each do |message| %>
|
62
|
-
|
63
|
-
<li><%= message %></li>
|
64
|
-
|
65
|
-
<% end %>
|
66
|
-
|
67
|
-
</ul>
|
68
|
-
|
69
|
-
</div>
|
70
|
-
|
71
|
-
<% end %>
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
<div class="form-group">
|
76
|
-
|
77
|
-
<div class="col-xs-2" align="right"><%= f.label :id, :class => 'control-label' %></div>
|
78
|
-
|
79
|
-
<div class="col-xs-4"><%= f.text_field :id, :class => "form-control" %></div>
|
80
|
-
|
81
|
-
</div>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
<div class="form-group">
|
86
|
-
|
87
|
-
<div class="col-xs-2" align="right"><%= f.label :re_name, :class => 'control-label' %></div>
|
88
|
-
|
89
|
-
<div class="col-xs-4"><%= f.text_field :re_name, :class => "form-control" %></div>
|
90
|
-
|
91
|
-
</div>
|
92
|
-
|
93
|
-
<div class="form-group">
|
94
|
-
|
95
|
-
<div class="col-xs-2" align="right"><%= f.label :re_title, :class => 'control-label' %></div>
|
96
|
-
|
97
|
-
<div class="col-xs-4"><%= f.text_field :re_title, :class => "form-control" %></div>
|
98
|
-
|
99
|
-
</div>
|
100
|
-
|
101
|
-
・
|
102
|
-
|
103
|
-
・
|
104
|
-
|
105
|
-
・
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
<%= f.submit nil, :class => 'btn btn-primary' %>
|
110
|
-
|
111
|
-
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
|
112
|
-
|
113
|
-
retrieve_lists_path, :class => 'btn btn-default' %>
|
114
|
-
|
115
|
-
<% end %>
|
116
|
-
|
117
|
-
```
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
SHOW画面
|
122
|
-
|
123
|
-
```RUBY
|
124
|
-
|
125
|
-
<%- model_class = RetrieveList -%>
|
126
|
-
|
127
|
-
<div class="page-header">
|
128
|
-
|
129
|
-
<h1><span class="glyphicon glyphicon-list-alt"> 詳細</span></h1>
|
130
|
-
|
131
|
-
</div>
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
<%= form_for @retrieve_list, :html => { :class => 'form-horizontal' } do |f| %>
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
<div class="form-group">
|
140
|
-
|
141
|
-
<div class="col-xs-2" align="right"><strong>ID</strong></div>
|
142
|
-
|
143
|
-
<div class="col-xs-10"><strong>R<%= sprintf("%05d",@retrieve_list.id) %></strong></div>
|
144
|
-
|
145
|
-
</div>
|
146
|
-
|
147
|
-
<div class="form-group">
|
148
|
-
|
149
|
-
<div class="col-xs-2" align="right"><strong>担当者名</strong></div>
|
150
|
-
|
151
|
-
<div class="col-xs-10"><strong><%= @retrieve_list.re_name %></strong></div>
|
152
|
-
|
153
|
-
</div>
|
154
|
-
|
155
|
-
<div class="form-group">
|
156
|
-
|
157
|
-
<div class="col-xs-2" align="right"><strong>作品名</strong></div>
|
158
|
-
|
159
|
-
<div class="col-xs-10"><strong><%= @retrieve_list.re_title %></strong></div>
|
160
|
-
|
161
|
-
</div>
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
<%= link_to t('.back', :default => t("helpers.links.back")),
|
166
|
-
|
167
|
-
retrieve_lists_path, :class => 'btn btn-default' %>
|
168
|
-
|
169
|
-
<%= link_to t('.edit', :default => t("helpers.links.edit")),
|
170
|
-
|
171
|
-
edit_retrieve_list_path(@retrieve_list), :class => 'btn btn-default' %>
|
172
|
-
|
173
|
-
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
174
|
-
|
175
|
-
|
45
|
+
これらのヒントで何かご教示できる方いましたら、宜しくお願いいたします。
|
176
|
-
|
177
|
-
:method => 'delete',
|
178
|
-
|
179
|
-
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
180
|
-
|
181
|
-
:class => 'btn btn-danger' %>
|
182
|
-
|
183
|
-
<%= link_to "複製",
|
184
|
-
|
185
|
-
update_new_retrieve_lists_path(@retrieve_list), :class => 'btn btn-default' %>
|
186
|
-
|
187
|
-
<% end %>
|
188
|
-
|
189
|
-
```
|
1
フォーム追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -39,3 +39,151 @@
|
|
39
39
|
end
|
40
40
|
|
41
41
|
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
登録画面
|
46
|
+
|
47
|
+
```RUBY
|
48
|
+
|
49
|
+
<%= form_for @retrieve_list, :html => { :class => 'form-horizontal' } do |f| %>
|
50
|
+
|
51
|
+
<% if @retrieve_list.errors.any? %>
|
52
|
+
|
53
|
+
<div id="error_explanation">
|
54
|
+
|
55
|
+
<h2><%= pluralize(@retrieve_list.errors.count, "error") %> prohibited this retrieve_list from being saved:</h2>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
<ul>
|
60
|
+
|
61
|
+
<% @retrieve_list.errors.full_messages.each do |message| %>
|
62
|
+
|
63
|
+
<li><%= message %></li>
|
64
|
+
|
65
|
+
<% end %>
|
66
|
+
|
67
|
+
</ul>
|
68
|
+
|
69
|
+
</div>
|
70
|
+
|
71
|
+
<% end %>
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<div class="form-group">
|
76
|
+
|
77
|
+
<div class="col-xs-2" align="right"><%= f.label :id, :class => 'control-label' %></div>
|
78
|
+
|
79
|
+
<div class="col-xs-4"><%= f.text_field :id, :class => "form-control" %></div>
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<div class="form-group">
|
86
|
+
|
87
|
+
<div class="col-xs-2" align="right"><%= f.label :re_name, :class => 'control-label' %></div>
|
88
|
+
|
89
|
+
<div class="col-xs-4"><%= f.text_field :re_name, :class => "form-control" %></div>
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<div class="form-group">
|
94
|
+
|
95
|
+
<div class="col-xs-2" align="right"><%= f.label :re_title, :class => 'control-label' %></div>
|
96
|
+
|
97
|
+
<div class="col-xs-4"><%= f.text_field :re_title, :class => "form-control" %></div>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
・
|
102
|
+
|
103
|
+
・
|
104
|
+
|
105
|
+
・
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<%= f.submit nil, :class => 'btn btn-primary' %>
|
110
|
+
|
111
|
+
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
|
112
|
+
|
113
|
+
retrieve_lists_path, :class => 'btn btn-default' %>
|
114
|
+
|
115
|
+
<% end %>
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
SHOW画面
|
122
|
+
|
123
|
+
```RUBY
|
124
|
+
|
125
|
+
<%- model_class = RetrieveList -%>
|
126
|
+
|
127
|
+
<div class="page-header">
|
128
|
+
|
129
|
+
<h1><span class="glyphicon glyphicon-list-alt"> 詳細</span></h1>
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
<%= form_for @retrieve_list, :html => { :class => 'form-horizontal' } do |f| %>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
<div class="form-group">
|
140
|
+
|
141
|
+
<div class="col-xs-2" align="right"><strong>ID</strong></div>
|
142
|
+
|
143
|
+
<div class="col-xs-10"><strong>R<%= sprintf("%05d",@retrieve_list.id) %></strong></div>
|
144
|
+
|
145
|
+
</div>
|
146
|
+
|
147
|
+
<div class="form-group">
|
148
|
+
|
149
|
+
<div class="col-xs-2" align="right"><strong>担当者名</strong></div>
|
150
|
+
|
151
|
+
<div class="col-xs-10"><strong><%= @retrieve_list.re_name %></strong></div>
|
152
|
+
|
153
|
+
</div>
|
154
|
+
|
155
|
+
<div class="form-group">
|
156
|
+
|
157
|
+
<div class="col-xs-2" align="right"><strong>作品名</strong></div>
|
158
|
+
|
159
|
+
<div class="col-xs-10"><strong><%= @retrieve_list.re_title %></strong></div>
|
160
|
+
|
161
|
+
</div>
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
<%= link_to t('.back', :default => t("helpers.links.back")),
|
166
|
+
|
167
|
+
retrieve_lists_path, :class => 'btn btn-default' %>
|
168
|
+
|
169
|
+
<%= link_to t('.edit', :default => t("helpers.links.edit")),
|
170
|
+
|
171
|
+
edit_retrieve_list_path(@retrieve_list), :class => 'btn btn-default' %>
|
172
|
+
|
173
|
+
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
174
|
+
|
175
|
+
retrieve_list_path(@retrieve_list),
|
176
|
+
|
177
|
+
:method => 'delete',
|
178
|
+
|
179
|
+
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
180
|
+
|
181
|
+
:class => 'btn btn-danger' %>
|
182
|
+
|
183
|
+
<%= link_to "複製",
|
184
|
+
|
185
|
+
update_new_retrieve_lists_path(@retrieve_list), :class => 'btn btn-default' %>
|
186
|
+
|
187
|
+
<% end %>
|
188
|
+
|
189
|
+
```
|