Understanding routes with :path in Ruby on Rails

Sorin

New Member
#1
I'm trying to understand routes in Ruby on Rails and it's very hard to find the right info just by googling. So this is my question: what routes does the following snippet define ?
Mã:
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
Thanks a lot !
 

Admin

Administrator
Thành viên BQT
#2
This is the output of the command rails routes
Mã:
    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
 
Top