Rails 将路由 url 更改为 root
Rails change route url to root
我现在在我的 Rails 4.2 应用程序上使用 url - https://example.org/causes/help-family What do I need to do to change the url's to look like this - https://example.org/help-family 没有 "causes" 控制器出现在路线中?
https://example.org/causes应该还会继续列出所有的原因。
这是我的路线文件的一部分。
resources :causes, only: [:new, :create, :index, :show] do
get :thankyou
resources :donations, only: [:new, :create, :show ]
end
谢谢!
你可以试试
get '/help-family', to: "causes#help-family"
你可以这样做:
resources :causes, path: '/', only: [:new, :create, :show] do
get :thankyou
get :index, path: 'causes', on: :collection
resources :donations, only: [:new, :create, :show ]
end
这是假设您只想在索引页的路径中保留 'causes'。
我现在在我的 Rails 4.2 应用程序上使用 url - https://example.org/causes/help-family What do I need to do to change the url's to look like this - https://example.org/help-family 没有 "causes" 控制器出现在路线中? https://example.org/causes应该还会继续列出所有的原因。
这是我的路线文件的一部分。
resources :causes, only: [:new, :create, :index, :show] do
get :thankyou
resources :donations, only: [:new, :create, :show ]
end
谢谢!
你可以试试
get '/help-family', to: "causes#help-family"
你可以这样做:
resources :causes, path: '/', only: [:new, :create, :show] do
get :thankyou
get :index, path: 'causes', on: :collection
resources :donations, only: [:new, :create, :show ]
end
这是假设您只想在索引页的路径中保留 'causes'。