我试图理解Ruby on Rails中的路由,仅通过谷歌搜索很难找到正确的信息。所以这是我的问题:以下代码段定义了哪些路由?
scope '/admin' do
resource :photo, :only => [:edit], :path => '/d/:domain_name', :domain_name => /[\.0-9a-zA-Z-]+/
resource :photo, :only => [:update], :path => '/d/:domain_name/edit', :domain_name => /[\.0-9a-zA-Z-]+/
resources :reviews, :only => [:index, :new, :create], :path => '/d/:domain_name/reviews', :domain_name => /[\.0-9a-zA-Z-]+/
resources :reviews, :except => [:index, :new, :create] request
end
非常感谢!
答案 0 :(得分:1)
运行此命令,您将获得结果
rails routes | grep /admin
此外,这是您使用的所有选项的文档:https://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing
答案 1 :(得分:1)
这是命令rails routes的输出
edit_photo GET /admin/d/:domain_name/edit(.:format) photos#edit {:domain_name=>/[\.0-9a-zA-Z-]+/}
photo PATCH /admin/d/:domain_name/edit(.:format) photos#update {:domain_name=>/[\.0-9a-zA-Z-]+/}
PUT /admin/d/:domain_name/edit(.:format) photos#update {:domain_name=>/[\.0-9a-zA-Z-]+/}
reviews GET /admin/d/:domain_name/reviews(.:format) reviews#index {:domain_name=>/[\.0-9a-zA-Z-]+/}
POST /admin/d/:domain_name/reviews(.:format) reviews#create {:domain_name=>/[\.0-9a-zA-Z-]+/}
new_review GET /admin/d/:domain_name/reviews/new(.:format) reviews#new {:domain_name=>/[\.0-9a-zA-Z-]+/}
edit_review GET /admin/reviews/:id/edit(.:format) reviews#edit
review GET /admin/reviews/:id(.:format) reviews#show
PATCH /admin/reviews/:id(.:format) reviews#update
PUT /admin/reviews/:id(.:format) reviews#update
DELETE /admin/reviews/:id(.:format) reviews#destroy