teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

resources :baggages, only: [:new, :show]をresources :baggages, only: [:new,:create, :show]に変更

2020/10/16 11:05

投稿

yukireonsousi
yukireonsousi

スコア3

title CHANGED
File without changes
body CHANGED
@@ -162,7 +162,7 @@
162
162
  get 'pages/show'
163
163
  devise_for :users
164
164
 
165
- resources :baggages, only: [:new, :show]
165
+ resources :baggages, only: [:new,:create, :show]
166
166
  namespace :admin do
167
167
  resources :baggages do
168
168
  collection do

1

エラー文とルーティングのコードの追加

2020/10/16 11:05

投稿

yukireonsousi
yukireonsousi

スコア3

title CHANGED
File without changes
body CHANGED
@@ -112,4 +112,68 @@
112
112
  = f.hidden_field :user_id
113
113
 
114
114
  = f.submit 'SEND', class: "baggage__send"
115
- ```
115
+ ```
116
+ エラー文
117
+ ```
118
+ NoMethodError in Admin::Baggages#new
119
+ Showing /Users/arimotoyuuki/projects/fusion/app/views/admin/baggages/new.html.haml where line #4 raised:
120
+
121
+ undefined method `baggages_path' for #<#<Class:0x00007fb0d88e2f48>:0x00007fb0ef5a1390>
122
+ Did you mean? baggage_path
123
+ Extracted source (around line #4):
124
+ 2
125
+ 3
126
+ 4
127
+ 5
128
+ 6
129
+ 7
130
+
131
+
132
+ .disply
133
+ = form_with model: @baggage do |f|
134
+
135
+ .baggage
136
+ .baggage__box
137
+
138
+ Rails.root: /Users/arimotoyuuki/projects/fusion
139
+
140
+ Application Trace | Framework Trace | Full Trace
141
+ app/views/admin/baggages/new.html.haml:4:in `_app_views_admin_baggages_new_html_haml___1924533726690858305_70198953314620'
142
+ Request
143
+ Parameters:
144
+
145
+ {"user_id"=>"1"}
146
+ Toggle session dump
147
+ Toggle env dump
148
+ Response
149
+ Headers:
150
+
151
+ None
152
+ x
153
+ >> params
154
+ => <ActionController::Parameters {"user_id"=>"1", "controller"=>"admin/baggages", "action"=>"new"} permitted: false>
155
+ >>
156
+ ```
157
+ **routes.rb**
158
+ ```
159
+ Rails.application.routes.draw do
160
+
161
+ root 'pages#index'
162
+ get 'pages/show'
163
+ devise_for :users
164
+
165
+ resources :baggages, only: [:new, :show]
166
+ namespace :admin do
167
+ resources :baggages do
168
+ collection do
169
+ get 'search'
170
+ end
171
+ end
172
+ end
173
+
174
+ end
175
+ ```
176
+ ```
177
+ get 'search'
178
+ ```
179
+ は使ってないから、削除した方がいいかもしれないですね