我想了解更多有关Rails路由的信息.
会员和收藏
# Example resource route with options:
resources :products do
member do
get 'short'
post 'toggle'
end
collection do
get 'sold'
end
end
Run Code Online (Sandbox Code Playgroud)
命名空间和范围
# Example resource route within a namespace:
namespace :admin do
resources :products
end
scope :admin do
resources :products
end
Run Code Online (Sandbox Code Playgroud)
约束,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
}
Run Code Online (Sandbox Code Playgroud)
定制:
resources :profiles
Run Code Online (Sandbox Code Playgroud)
来自resource profiles编辑的原始网址.
http://localhost:3000/profiles/1/edit
Run Code Online (Sandbox Code Playgroud)
我想为只有点击的用户提供它,edit profile …