Ruby on rails 重写路由跳过控制器名称
我想在没有控制器名称的情况下访问以下路径 e、 g.Ruby on rails 重写路由跳过控制器名称,ruby-on-rails,Ruby On Rails,我想在没有控制器名称的情况下访问以下路径 e、 g.SITE/aboutSITE/faq 怎么做 routes.rb 指定url的使用方式以及要访问的控制器和控制器方法 例如,在您的routes.rb中 get 'about', to: 'pages#about' 这样,example.com/about将在PagesController中指向actionabout,尝试以下操作: scope '/', controller: 'welcome' do get :index get :
SITE/about
SITE/faq
怎么做
routes.rb
指定url的使用方式以及要访问的控制器和控制器方法 例如,在您的routes.rb中
get 'about', to: 'pages#about'
这样,example.com/about
将在PagesController
中指向actionabout
,尝试以下操作:
scope '/', controller: 'welcome' do
get :index
get :about
get :brand
get :product
get :news
get :faq
get :download
get :contact
end
它还允许您忘记在每行中写入控制器名称
scope '/', controller: 'welcome' do
get :index
get :about
get :brand
get :product
get :news
get :faq
get :download
get :contact
end