我想了解更多有关Rails路由的信息。
会员和收藏
# Example resource route with options:
resources :products do
member do
get 'short'
post 'toggle'
end
collection do
get 'sold'
end
end
命名空间和范围
# Example resource route within a namespace:
namespace :admin do
resources :products
end
scope :admin do
resources :products
end
约束,Redirect_to
# Example resource route with options:
get "/questions", to: redirect {|params, req|
begin
id = req.params[:category_id]
cat = Category.find(id)
"/abc/#{cat.slug}"
rescue
"/questions"
end
}
定制
resources :profiles
来自resource profiles
的原始网址进行修改。
http://localhost:3000/profiles/1/edit
我想通过点击edit profile
向用户提供,并在下方查看网址。
http://localhost:3000/profile/edit
此外,是否有高级路由,大多数大公司如何设计他们的铁路路线?如果有的话,我会很高兴看到新的路线。
谢谢!