質問編集履歴

3

routes\.rb rake routes  に少しの書き込みをしました。

2016/04/10 03:06

投稿

M8KzBFdJPyD1kKd
M8KzBFdJPyD1kKd

スコア26

test CHANGED
File without changes
test CHANGED
@@ -331,3 +331,237 @@
331
331
  end
332
332
 
333
333
  ```
334
+
335
+
336
+
337
+ ---
338
+
339
+ routes.rb です
340
+
341
+ ---
342
+
343
+ ```
344
+
345
+ Rails.application.routes.draw do
346
+
347
+ resources :notes
348
+
349
+ get '/top' => 'home#top'
350
+
351
+ get '/about' => 'home#about'
352
+
353
+
354
+
355
+ devise_for :users
356
+
357
+ resources :users,only:[:index,:show,:edit,:update]
358
+
359
+ # The priority is based upon order of creation: first created -> highest priority.
360
+
361
+ # See how all your routes lay out with "rake routes".
362
+
363
+
364
+
365
+ # You can have the root of your site routed with "root"
366
+
367
+ root 'home#top'
368
+
369
+
370
+
371
+ # Example of regular route:
372
+
373
+ # get 'products/:id' => 'catalog#view'
374
+
375
+
376
+
377
+ # Example of named route that can be invoked with purchase_url(id: product.id)
378
+
379
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
380
+
381
+
382
+
383
+ # Example resource route (maps HTTP verbs to controller actions automatically):
384
+
385
+ # resources :products
386
+
387
+
388
+
389
+ # Example resource route with options:
390
+
391
+ # resources :products do
392
+
393
+ # member do
394
+
395
+ # get 'short'
396
+
397
+ # post 'toggle'
398
+
399
+ # end
400
+
401
+ #
402
+
403
+ # collection do
404
+
405
+ # get 'sold'
406
+
407
+ # end
408
+
409
+ # end
410
+
411
+
412
+
413
+ # Example resource route with sub-resources:
414
+
415
+ # resources :products do
416
+
417
+ # resources :comments, :sales
418
+
419
+ # resource :seller
420
+
421
+ # end
422
+
423
+
424
+
425
+ # Example resource route with more complex sub-resources:
426
+
427
+ # resources :products do
428
+
429
+ # resources :comments
430
+
431
+ # resources :sales do
432
+
433
+ # get 'recent', on: :collection
434
+
435
+ # end
436
+
437
+ # end
438
+
439
+
440
+
441
+ # Example resource route with concerns:
442
+
443
+ # concern :toggleable do
444
+
445
+ # post 'toggle'
446
+
447
+ # end
448
+
449
+ # resources :posts, concerns: :toggleable
450
+
451
+ # resources :photos, concerns: :toggleable
452
+
453
+
454
+
455
+ # Example resource route within a namespace:
456
+
457
+ # namespace :admin do
458
+
459
+ # # Directs /admin/products/* to Admin::ProductsController
460
+
461
+ # # (app/controllers/admin/products_controller.rb)
462
+
463
+ # resources :products
464
+
465
+ # end
466
+
467
+ end
468
+
469
+ ```
470
+
471
+ ---
472
+
473
+ rake routesです。
474
+
475
+ ---
476
+
477
+ ```
478
+
479
+ Prefix Verb URI Pattern Controller#Action
480
+
481
+ notes GET /notes(.:format) notes#index
482
+
483
+ POST /notes(.:format) notes#create
484
+
485
+ new_note GET /notes/new(.:format) notes#new
486
+
487
+ edit_note GET /notes/:id/edit(.:format) notes#edit
488
+
489
+ note GET /notes/:id(.:format) notes#show
490
+
491
+ PATCH /notes/:id(.:format) notes#update
492
+
493
+ PUT /notes/:id(.:format) notes#update
494
+
495
+ DELETE /notes/:id(.:format) notes#destroy
496
+
497
+ top GET /top(.:format) home#top
498
+
499
+ about GET /about(.:format) home#about
500
+
501
+ new_user_session GET /users/sign_in(.:format) devise/sessions#new
502
+
503
+ user_session POST /users/sign_in(.:format) devise/sessions#create
504
+
505
+ destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
506
+
507
+ user_password POST /users/password(.:format) devise/passwords#create
508
+
509
+ new_user_password GET /users/password/new(.:format) devise/passwords#new
510
+
511
+ edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
512
+
513
+ PATCH /users/password(.:format) devise/passwords#update
514
+
515
+ PUT /users/password(.:format) devise/passwords#update
516
+
517
+ cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
518
+
519
+ user_registration POST /users(.:format) devise/registrations#create
520
+
521
+ new_user_registration GET /users/sign_up(.:format) devise/registrations#new
522
+
523
+ edit_user_registration GET /users/edit(.:format) devise/registrations#edit
524
+
525
+ PATCH /users(.:format) devise/registrations#update
526
+
527
+ PUT /users(.:format) devise/registrations#update
528
+
529
+ DELETE /users(.:format) devise/registrations#destroy
530
+
531
+ users GET /users(.:format) users#index
532
+
533
+ edit_user GET /users/:id/edit(.:format) users#edit
534
+
535
+ user GET /users/:id(.:format) users#show
536
+
537
+ PATCH /users/:id(.:format) users#update
538
+
539
+ PUT /users/:id(.:format) users#update
540
+
541
+ root GET / home#top
542
+
543
+ ```
544
+
545
+
546
+
547
+ 参考にしたのはpurogateという学習サイトです。
548
+
549
+ 最近有料になったので、掲載が難しいです。
550
+
551
+ http://prog-8.com/lessons/rails/intermediate
552
+
553
+
554
+
555
+ railsの中級の一番最後にプロフィール画像を載せようってのがありまして、それをしました。
556
+
557
+
558
+
559
+ ただし、中級の学習ではdevise は使っていません。
560
+
561
+
562
+
563
+ イメージは、サイトへの会員登録の際に、自分の画像を登録できるようにしたいのです。
564
+
565
+
566
+
567
+ SNSでよくある自分流の画像の登録です。

2

コードに「```」をかましました!

2016/04/10 03:06

投稿

M8KzBFdJPyD1kKd
M8KzBFdJPyD1kKd

スコア26

test CHANGED
File without changes
test CHANGED
@@ -36,6 +36,8 @@
36
36
 
37
37
  ---
38
38
 
39
+ ```
40
+
39
41
  source 'https://rubygems.org'
40
42
 
41
43
 
@@ -96,6 +98,8 @@
96
98
 
97
99
  end
98
100
 
101
+ ```
102
+
99
103
 
100
104
 
101
105
  ---
@@ -104,6 +108,10 @@
104
108
 
105
109
  ---
106
110
 
111
+
112
+
113
+ ```
114
+
107
115
  class UsersController < ApplicationController
108
116
 
109
117
 
@@ -196,6 +204,8 @@
196
204
 
197
205
  end
198
206
 
207
+ ```
208
+
199
209
 
200
210
 
201
211
  ---
@@ -204,6 +214,10 @@
204
214
 
205
215
  ---
206
216
 
217
+
218
+
219
+ ```
220
+
207
221
  <%= bootstrap_devise_error_messages! %>
208
222
 
209
223
  <div class="panel panel-default devise-bs">
@@ -315,3 +329,5 @@
315
329
 
316
330
 
317
331
  end
332
+
333
+ ```

1

分かりやすくしたつもりです。gemfileを追加しました。

2016/04/10 01:55

投稿

M8KzBFdJPyD1kKd
M8KzBFdJPyD1kKd

スコア26

test CHANGED
File without changes
test CHANGED
@@ -16,7 +16,9 @@
16
16
 
17
17
  エラーは出ないが思ったような動作をしてくれていない。
18
18
 
19
- rails cで User.lastを見るとファイル名のカラムであるimage「<ActionDispatch::Http::UploadedFile・・・」とヘンテコな名前になっているし。
19
+ rails cで User.lastを見ると付け加えたimageカラムに「<ActionDispatch::Http::UploadedFile・・・」とヘンテコなファイルが入っているし。こんな変なファイル名じゃない!
20
+
21
+
20
22
 
21
23
  実際の画像ファイル名も、「RackMultipart20160409-5687-fplocs.jp」だとか勝手に変な名前になって、しかも入れたいフォルダ(public/user_images)に入っていない。Gemfileの隣に保存されているんだ・・・
22
24
 
@@ -28,7 +30,75 @@
28
30
 
29
31
  ###該当のソースコード
30
32
 
31
-
33
+ ---
34
+
35
+ gemfile
36
+
37
+ ---
38
+
39
+ source 'https://rubygems.org'
40
+
41
+
42
+
43
+ gem 'rails', '4.2.2'
44
+
45
+ gem 'sass-rails', '5.0.2'
46
+
47
+ gem 'uglifier', '2.5.3'
48
+
49
+ gem 'coffee-rails', '4.1.0'
50
+
51
+ gem 'jquery-rails', '4.0.3'
52
+
53
+ gem 'turbolinks', '2.3.0'
54
+
55
+ gem 'jbuilder', '2.2.3'
56
+
57
+ gem 'sdoc', '0.4.0', group: :doc
58
+
59
+
60
+
61
+ gem 'devise'
62
+
63
+ gem 'devise-bootstrap-views'
64
+
65
+ gem 'devise-i18n'
66
+
67
+ gem 'devise-i18n-views'
68
+
69
+
70
+
71
+ gem 'honoka-rails', '>= 3.3.6.3'
72
+
73
+
74
+
75
+
76
+
77
+ group :development, :test do
78
+
79
+ gem 'sqlite3', '1.3.9'
80
+
81
+ gem 'byebug', '3.4.0'
82
+
83
+ gem 'web-console', '2.0.0.beta3'
84
+
85
+ gem 'spring', '1.1.3'
86
+
87
+ end
88
+
89
+
90
+
91
+ group :production do
92
+
93
+ gem 'pg', '0.17.1'
94
+
95
+ gem 'rails_12factor', '0.0.2'
96
+
97
+ end
98
+
99
+
100
+
101
+ ---
32
102
 
33
103
  users_controller.rb です。
34
104