一旦我们将Rails应用程序部署到AWS-EC2,但是当我们完成路由时,一切就变得一团糟。Rails希望以www.example.com/为根。我们希望www.example.com/myapp成为Rails的根路径。
路线
Rails.application.routes.draw do
resources :forms do
collection do
post :accept_item
end
end
resources :stores, m:'true'
match '/send_mail', to: 'stores#send_mail', via: 'post'
get 'products' => 'products#index', m:'true'
get 'stores' => 'stores#index', m:'true'
get 'transactions' => 'transactions#index', m:'true'
get 'inventories' => 'inventories#index', m:'true'
get 'about' => 'sites#about'
get 'man' => 'sites#index', m:'true'
root 'sites#index'
end
为什么不将所有路由都包装在一个范围内的路由文件中,例如:
scope path: '/myapp' do
#routes here
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句