RoutingError 没有路由匹配
RoutingError No route matches
我正在尝试访问来自不同 haml
的控制器的新操作
= button_to 'Demo', new_demo_path, {class: 'btn btn-primary btn-sm'}
但我收到错误消息:
No route matches
我的路线已有路径:
/demos/new(.:format)
也在我的路线文件中:
resources :demos
我在这里错过了什么?
您不需要 /demos/new(.:format)
,因为 resources :demos
会创建 Crud Actions
,包括 new
,重新启动服务器并再次检查。
还需要添加method: :get
作为button_to默认生成方法post
改变
= button_to 'Demo', new_demos_path, {class: 'btn btn-primary btn-sm'}
到
= button_to 'Demo', new_demo_path, method: :get, {class: 'btn btn-primary btn-sm'}
我正在尝试访问来自不同 haml
= button_to 'Demo', new_demo_path, {class: 'btn btn-primary btn-sm'}
但我收到错误消息:
No route matches
我的路线已有路径:
/demos/new(.:format)
也在我的路线文件中:
resources :demos
我在这里错过了什么?
您不需要 /demos/new(.:format)
,因为 resources :demos
会创建 Crud Actions
,包括 new
,重新启动服务器并再次检查。
还需要添加method: :get
作为button_to默认生成方法post
改变
= button_to 'Demo', new_demos_path, {class: 'btn btn-primary btn-sm'}
到
= button_to 'Demo', new_demo_path, method: :get, {class: 'btn btn-primary btn-sm'}