I have a controller called crm_controller
. It is a jumping-off point for application administrators. It has a method called index
, which will be the home page. More will be added later.
我有一个名为crm_controller的控制器。它是应用程序管理员的起点。它有一个名为index的方法,它将成为主页。稍后会添加更多内容。
But it's important to note that the controller is called crm_controller
. Not crms_controller
. It is not a resource.
但重要的是要注意控制器名为crm_controller。不是crms_controller。它不是资源。
All I want is for a helper method called crm_path
to exist, and to route to crm#index
. It has been over a year since I have created an application from scratch. I am having trouble penetrating the routing documentation. How can I do this?
我想要的只是存在一个名为crm_path的辅助方法,并路由到crm #index。自从我从头开始创建应用程序已有一年多了。我无法浏览路由文档。我怎样才能做到这一点?
1 个解决方案
#1
0
If it's your root path, you could do:
如果这是你的根路径,你可以这样做:
get '/', to: 'crm#index', as: :crm
得到'/',到:'crm #index',如::: crm
You'd want to remove the root
route from your routes file if you use the above.
如果使用上述方法,则需要从路径文件中删除根路径。
Otherwise, if you have specific path you want this to land on, you could do:
否则,如果你有特定的路径,你想要这个,你可以这样做:
get '<path>', to: 'crm#index', as: :crm
得到'
#1
0
If it's your root path, you could do:
如果这是你的根路径,你可以这样做:
get '/', to: 'crm#index', as: :crm
得到'/',到:'crm #index',如::: crm
You'd want to remove the root
route from your routes file if you use the above.
如果使用上述方法,则需要从路径文件中删除根路径。
Otherwise, if you have specific path you want this to land on, you could do:
否则,如果你有特定的路径,你想要这个,你可以这样做:
get '<path>', to: 'crm#index', as: :crm
得到'