Mit*_*ran 1 routes ruby-on-rails
我收到URL http:// localhost:3000/dashboard /的错误
Routing Error No route matches "/dashboard"
但http:// localhost:3000/dashboard/index工作正常
如何使以下所有URL工作并显示相同的视图 views/dashboard/index.html.erb
http://localhost:3000
http://localhost:3000/
http://localhost:3000/dashboard
http://localhost:3000/dashboard/
http://localhost:3000/dashboard/index
Run Code Online (Sandbox Code Playgroud)
我的路线文件是
Mytest::Application.routes.draw do
get "dashboard/index"
root :to => "dashboard#index"
end
Run Code Online (Sandbox Code Playgroud)
我的控制器文件是
class DashboardController < ApplicationController
def index
end
end
Run Code Online (Sandbox Code Playgroud)
Mytest::Application.routes.draw do
match "/dashboard", :to => 'dashboard#index'
root :to => "dashboard#index"
end
Run Code Online (Sandbox Code Playgroud)
您还可以添加/:controller/:action/:id(.:format)样式的通用路径.