質問編集履歴
3
rails routesの実行結果を記載いたしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -81,4 +81,21 @@
|
|
81
81
|
```
|
82
82
|
しかし上記でもNoMethodErrorと出てしまいます。root_pathにした場合動作はするので、やはりpathhelper名が間違えているようです。
|
83
83
|
>rails routes で調べる方法
|
84
|
-
申し訳ありませんが上記がわからないためどのようなことをすればよいか教えていただけないでしょうか。
|
84
|
+
申し訳ありませんが上記がわからないためどのようなことをすればよいか教えていただけないでしょうか。
|
85
|
+
|
86
|
+
-----------------------------------------
|
87
|
+
rails routesを実行した結果の一部を記載いたします。
|
88
|
+
何度も申し訳ありませんがご確認お願いいたします。
|
89
|
+
重要そうなところを抜粋したつもりですが抜けがありましたらおしえてください。
|
90
|
+
```
|
91
|
+
Controller#Action
|
92
|
+
root GET / home#top
|
93
|
+
GET /ownersinfo/:id/home(.:format) ownersinfo#home
|
94
|
+
ownersinfo_new GET /ownersinfo/new(.:format) ownersinfo#new
|
95
|
+
GET /ownersinfo/:id/edit(.:format) ownersinfo#edit
|
96
|
+
POST /ownersinfo/:id/update(.:format) ownersinfo#update
|
97
|
+
POST /ownersinfo/:id/reset_image(.:format) ownersinfo#reset_image
|
98
|
+
home_top GET /home/top(.:format) home#top
|
99
|
+
home_search GET /home/search(.:format) home#search
|
100
|
+
home_keyword_search GET /home/keyword_search(.:format) home#keyword_search
|
101
|
+
```
|
2
pathhelperについて試したことを記載しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -59,4 +59,26 @@
|
|
59
59
|
rootは一旦アプリケーションのトップに遷移するようにしていますが、
|
60
60
|
遷移したいのは"ownersinfo#home"になります。
|
61
61
|
ownersinfo_home_path等試しましたが、引数が必要なためかルーティングがうまくいきませんでした。
|
62
|
-
他に追記する必要がある情報等ありましたらお手数ですがまた教えていただけないでしょうか。
|
62
|
+
他に追記する必要がある情報等ありましたらお手数ですがまた教えていただけないでしょうか。
|
63
|
+
|
64
|
+
ーーーーーーーーーーーーーーーーーーーーーーーーーー
|
65
|
+
pathhelper名ですが、[_urlや_pathといったヘルパーメソッドの使い方](https://qiita.com/Shugo_Y/items/412d7660f259eddf9c66)を参考に下記のようにroutesとcontroller書き直してみました。
|
66
|
+
```
|
67
|
+
get "ownersinfos/:id/edit" => "ownersinfo#edit"
|
68
|
+
```
|
69
|
+
(ownersinfoを複数形にしました)
|
70
|
+
```
|
71
|
+
application_controller.rb
|
72
|
+
|
73
|
+
def after_sign_in_path_for(resource)
|
74
|
+
case resource
|
75
|
+
when Owner
|
76
|
+
edit_ownersinfo_path(:id)
|
77
|
+
when User
|
78
|
+
users_home_path
|
79
|
+
end
|
80
|
+
end
|
81
|
+
```
|
82
|
+
しかし上記でもNoMethodErrorと出てしまいます。root_pathにした場合動作はするので、やはりpathhelper名が間違えているようです。
|
83
|
+
>rails routes で調べる方法
|
84
|
+
申し訳ありませんが上記がわからないためどのようなことをすればよいか教えていただけないでしょうか。
|
1
routes.rbについて省略無しで追記いたしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -25,4 +25,38 @@
|
|
25
25
|
get 'ownersinfo/:id/home' => "ownersinfo#home"
|
26
26
|
```
|
27
27
|
いくつかpathの設定を検索して記載してみたのですが、各々引数が必要なルーティングにしてしまったせいか、エラーが出てしまいました。
|
28
|
-
記載した内容以外で判断に必要な情報がありましたら追記いたしますのでお手数ですが教えていただけないでしょうか。
|
28
|
+
記載した内容以外で判断に必要な情報がありましたら追記いたしますのでお手数ですが教えていただけないでしょうか。
|
29
|
+
|
30
|
+
routes.rbについて省略無しで追記します。
|
31
|
+
```
|
32
|
+
Rails.application.routes.draw do
|
33
|
+
|
34
|
+
root "home#top"
|
35
|
+
get 'ownersinfo/:id/home' => "ownersinfo#home"
|
36
|
+
get "ownersinfo/new" => "ownersinfo#new"
|
37
|
+
get "ownersinfo/:id/edit" => "ownersinfo#edit"
|
38
|
+
post "ownersinfo/:id/update" => "ownersinfo#update"
|
39
|
+
post "ownersinfo/:id/reset_image" => "ownersinfo#reset_image"
|
40
|
+
get "home/top" => "home#top"
|
41
|
+
get "home/search" => "home#search"
|
42
|
+
get "home/keyword_search" => "home#keyword_search"
|
43
|
+
|
44
|
+
devise_for :owners, controllers: {
|
45
|
+
sessions: 'owners/sessions',
|
46
|
+
passwords: 'owners/passwords',
|
47
|
+
registrations: 'owners/registrations'
|
48
|
+
}
|
49
|
+
devise_for :users, controllers: {
|
50
|
+
sessions: 'users/sessions',
|
51
|
+
passwords: 'users/passwords',
|
52
|
+
registrations: 'users/registrations'
|
53
|
+
}
|
54
|
+
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
|
55
|
+
end
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
rootは一旦アプリケーションのトップに遷移するようにしていますが、
|
60
|
+
遷移したいのは"ownersinfo#home"になります。
|
61
|
+
ownersinfo_home_path等試しましたが、引数が必要なためかルーティングがうまくいきませんでした。
|
62
|
+
他に追記する必要がある情報等ありましたらお手数ですがまた教えていただけないでしょうか。
|