ruby-on-rails - 尝试设置路由路径,但没有路由匹配
问题描述
我在设置视图时遇到了大问题.. 每当我进入我的页面 localhost/clear 时,我都会得到
No route matches [GET] "/clear".
我的控制器中有一个名为 clear 的文件夹,其中包含控制器文件。
我如何将其设置为:
localhost/clear as main view,
and other one as
localhost/clear/connect
localhost/clear/test
base_controller.rb
class Clear::BaseController < ApplicationController
def index
end
end
连接控制器.rb
class Clear::ConnectController< Clear::BaseController
def index
@functions
end
end
路线.rb
resources :clear, only: :index
namespace :clear do
resources :connect, only: :index
resources :test, only: :index
end
解决方案
你错过了路线/clear
# routes.rb
namespace :clear do
resources :base, only: :index, path: '/'
resources :connect, only: :index
resources :test, only: :index
end
这是检查您拥有哪些路线的方法
rake routes | grep clear
# =>
clear_base_index GET /clear(.:format) clear/base#index
clear_connect_index GET /clear/connect(.:format) clear/connect#index
clear_test_index GET /clear/test(.:format) clear/test#ind
推荐阅读
- prometheus - 如何在 Prometheus 中为磁盘空间配置警报
- kubernetes - 启动多个 kafka 代理失败
- laravel - 为什么我上传的某些视频编码失败(laravel ffmpeg)
- javascript - 用 jQuery 附加 html 元素 - html、DOM 和 jQuery 附加之间的区别?
- java - 归并排序中的子数组大小
- html - 如何使用 :after 在元素之后创建箭头形状
- python - Python:内存模型 ID
- javascript - 如何检测脚本是否在模块中运行?
- git - 将新提交的更改应用到旧提交,而无需中间提交
- python - 派格莱特。如何动态更改顶点的图片(动画)。OpenGL