質問編集履歴
1
質問された内容を加筆しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -161,3 +161,173 @@
|
|
161
161
|
</header>
|
162
162
|
|
163
163
|
```
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
※ 追記分です
|
168
|
+
|
169
|
+
```Ruby
|
170
|
+
|
171
|
+
SampleApp::Application.routes.draw do
|
172
|
+
|
173
|
+
resources :users
|
174
|
+
|
175
|
+
resources :sessions, only: [:new, :create, :destroy]
|
176
|
+
|
177
|
+
root 'static_pages#home'
|
178
|
+
|
179
|
+
match '/signup', to: 'users#new', via: 'get'
|
180
|
+
|
181
|
+
match '/signin', to: 'sessions#new', via: 'get'
|
182
|
+
|
183
|
+
match '/signout', to: 'sessions#destroy', via: 'delete'
|
184
|
+
|
185
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
186
|
+
|
187
|
+
# See how all your routes lay out with "rake routes".
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
# You can have the root of your site routed with "root"
|
192
|
+
|
193
|
+
# root 'welcome#index'
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
# Example of regular route:
|
198
|
+
|
199
|
+
# get 'products/:id' => 'catalog#view'
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
204
|
+
|
205
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
210
|
+
|
211
|
+
# resources :products
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
# Example resource route with options:
|
216
|
+
|
217
|
+
# resources :products do
|
218
|
+
|
219
|
+
# member do
|
220
|
+
|
221
|
+
# get 'short'
|
222
|
+
|
223
|
+
# post 'toggle'
|
224
|
+
|
225
|
+
# end
|
226
|
+
|
227
|
+
#
|
228
|
+
|
229
|
+
# collection do
|
230
|
+
|
231
|
+
# get 'sold'
|
232
|
+
|
233
|
+
# end
|
234
|
+
|
235
|
+
# end
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
# Example resource route with sub-resources:
|
240
|
+
|
241
|
+
# resources :products do
|
242
|
+
|
243
|
+
# resources :comments, :sales
|
244
|
+
|
245
|
+
# resource :seller
|
246
|
+
|
247
|
+
# end
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
# Example resource route with more complex sub-resources:
|
252
|
+
|
253
|
+
# resources :products do
|
254
|
+
|
255
|
+
# resources :comments
|
256
|
+
|
257
|
+
# resources :sales do
|
258
|
+
|
259
|
+
# get 'recent', on: :collection
|
260
|
+
|
261
|
+
# end
|
262
|
+
|
263
|
+
# end
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
# Example resource route with concerns:
|
268
|
+
|
269
|
+
# concern :toggleable do
|
270
|
+
|
271
|
+
# post 'toggle'
|
272
|
+
|
273
|
+
# end
|
274
|
+
|
275
|
+
# resources :posts, concerns: :toggleable
|
276
|
+
|
277
|
+
# resources :photos, concerns: :toggleable
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
# Example resource route within a namespace:
|
282
|
+
|
283
|
+
# namespace :admin do
|
284
|
+
|
285
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
286
|
+
|
287
|
+
# # (app/controllers/admin/products_controller.rb)
|
288
|
+
|
289
|
+
# resources :products
|
290
|
+
|
291
|
+
# end
|
292
|
+
|
293
|
+
end
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
```
|
298
|
+
|
299
|
+
rake routesの結果は下記となります!
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
Prefix Verb URI Pattern Controller#Action
|
304
|
+
|
305
|
+
users GET /users(.:format) users#index
|
306
|
+
|
307
|
+
POST /users(.:format) users#create
|
308
|
+
|
309
|
+
new_user GET /users/new(.:format) users#new
|
310
|
+
|
311
|
+
edit_user GET /users/:id/edit(.:format) users#edit
|
312
|
+
|
313
|
+
user GET /users/:id(.:format) users#show
|
314
|
+
|
315
|
+
PATCH /users/:id(.:format) users#update
|
316
|
+
|
317
|
+
PUT /users/:id(.:format) users#update
|
318
|
+
|
319
|
+
DELETE /users/:id(.:format) users#destroy
|
320
|
+
|
321
|
+
sessions POST /sessions(.:format) sessions#create
|
322
|
+
|
323
|
+
new_session GET /sessions/new(.:format) sessions#new
|
324
|
+
|
325
|
+
session DELETE /sessions/:id(.:format) sessions#destroy
|
326
|
+
|
327
|
+
root GET / static_pages#home
|
328
|
+
|
329
|
+
signup GET /signup(.:format) users#new
|
330
|
+
|
331
|
+
signin GET /signin(.:format) sessions#new
|
332
|
+
|
333
|
+
signout DELETE /signout(.:format) sessions#destroy
|