質問編集履歴

3

情報の修正

2019/01/24 05:19

投稿

s_diff
s_diff

スコア107

test CHANGED
File without changes
test CHANGED
@@ -48,9 +48,9 @@
48
48
 
49
49
 
50
50
 
51
- > manage/productsコントローラのnewメソッドどのような形で呼び出していますか?
51
+ bundle exec rake routesで出力されるmanage/productsコントローラのnewメソッドの箇所
52
52
 
53
- bundle exec rake routesで出力されるmanage/productsコントローラのnewメソッドの箇所は
53
+ >
54
54
 
55
55
  new_manage_product GET /manage/products/new(.:format) manage/products#new
56
56
 

2

情報の追加

2019/01/24 05:19

投稿

s_diff
s_diff

スコア107

test CHANGED
File without changes
test CHANGED
@@ -48,4 +48,150 @@
48
48
 
49
49
 
50
50
 
51
+ > 「manage/productsコントローラのnewメソッド」はどのような形で呼び出していますか?
52
+
53
+ bundle exec rake routesで出力されるmanage/productsコントローラのnewメソッドの箇所は
54
+
55
+ new_manage_product GET /manage/products/new(.:format) manage/products#new
56
+
57
+ です。
58
+
59
+
60
+
61
+ productsコントローラのnewメソッドとビューのコードは以下です。
62
+
63
+ ```ruby
64
+
65
+ def new
66
+
67
+ p_params = { area_id: params[:area_id], building_name: params[:building_name], station: params[:station], address: params[:address], floor: params[:floor] }
68
+
69
+ @product = Product.new(p_params)
70
+
71
+ @product_images = []
72
+
73
+ end
74
+
75
+ ```
76
+
77
+
78
+
79
+ ```ruby
80
+
81
+ <h2 class="head2">new</h2>
82
+
83
+
84
+
85
+ <%= render 'form' %>
86
+
87
+ ```
88
+
89
+
90
+
91
+ ```ruby
92
+
93
+ manage/products/_form.html.erb
94
+
95
+
96
+
97
+ <%= form_for([:manage,@product]) do |f| %>
98
+
99
+ <% if @product.errors.any? %>
100
+
101
+ <div class="alert-error">
102
+
103
+ <p class="error-msg">エラーが発生しました</p>
104
+
105
+ <ul>
106
+
107
+ <% @product.errors.full_messages.each do |alert| %>
108
+
109
+ <li><%= alert %></li>
110
+
111
+ <% end %>
112
+
113
+ </ul>
114
+
115
+ </div>
116
+
117
+ <% end %>
118
+
119
+ <div class="input manage-product-create-form">
120
+
121
+ <p class="row"><%= f.label :area_id, class: "label" %><%= f.select :area_id, @areas.map{ |t| [t.name, t.id] }, include_blank: true %></p>
122
+
123
+ <p class="row"><%= f.label :building_name, class: "label" %><%= f.text_field :building_name %></p>
124
+
125
+ <p class="row"><%= f.label :number, class: "label" %><%= f.text_field :number %></p>
126
+
127
+ <p class="row"><%= f.label :floor, class: "label" %><%= f.select :floor, Request::FLOOR, include_blank: true %></p>
128
+
129
+ <p class="row"><%= f.label :station, class: "label" %><%= f.text_field :station %></p>
130
+
131
+ <p class="row"><%= f.label :address, class: "label" %><%= f.text_field :address %></p>
132
+
133
+ <p class="row" id="js-selectFile">
134
+
135
+ <%= f.label :zip, class: "label" %>
136
+
137
+ <%= f.file_field :zip, id: "js-upload" %>
138
+
139
+ <%= f.hidden_field :zip_cache, id: "js-upload-cache" %>
140
+
141
+ <button class="original-btn">ZIPファイルを選択</button>
142
+
143
+ <span class="icon">未選択</span>
144
+
145
+ </p>
146
+
147
+ <div class="sort-box-container sortable">
148
+
149
+ <% (1..30).each do |num| %>
150
+
151
+ <div class="sort-box">
152
+
153
+ <div id="<%= num %>" class="input-group">
154
+
155
+ <%= f.file_field :"products_image#{num}", class: "uploadFile" %>
156
+
157
+ </div>
158
+
159
+ <input type="text" class="form-control" readonly="">
160
+
161
+ <input type="hidden" id="result" name="result" />
162
+
163
+ <div class="imagePreview item">
164
+
165
+ </div>
166
+
167
+ </div>
168
+
169
+ <% end %>
170
+
171
+ </div>
172
+
173
+ </div>
174
+
175
+ <div class="actions">
176
+
177
+ <%= button_tag type: 'submit', id: "submit", class: "btn-edit" do %>
178
+
179
+ <i class="fa fa-pencil" aria-hidden="true"></i> 作成
180
+
181
+ <% end %>
182
+
183
+ <%= link_to manage_products_path, class: "btn-back set-ml-10" do %>
184
+
185
+ <i class="fa fa-arrow-circle-left" aria-hidden="true"></i> 一覧に戻る
186
+
187
+ <% end %>
188
+
189
+ </div>
190
+
191
+ <% end %>
192
+
193
+ ```
194
+
195
+
196
+
51
197
  何かご教示いただけることがありましたら、ご教示の方よろしくお願いいたします。

1

情報の追加

2019/01/24 05:19

投稿

s_diff
s_diff

スコア107

test CHANGED
File without changes
test CHANGED
@@ -18,6 +18,14 @@
18
18
 
19
19
  ### ルーティング
20
20
 
21
+
22
+
23
+ ```ruby
24
+
25
+ #config/routes.rb
26
+
27
+
28
+
21
29
  namespace :manage do
22
30
 
23
31
  resources :products do
@@ -36,6 +44,8 @@
36
44
 
37
45
  end
38
46
 
47
+ ```
48
+
39
49
 
40
50
 
41
51
  何かご教示いただけることがありましたら、ご教示の方よろしくお願いいたします。