Ruby on rails 3 Rails 3:这条路线有什么作用?
想了解一下这条路线的工作原理吗 新路线:Ruby on rails 3 Rails 3:这条路线有什么作用?,ruby-on-rails-3,routes,Ruby On Rails 3,Routes,想了解一下这条路线的工作原理吗 新路线: resources :artists do resources :users end 全线 这将创建嵌套路由,允许您使用URL,如/artists/5/users/45,它将调用UsersController#show,其中参数artist\u id为5,参数id为45。所有其他常用的RESTful路由也都是在一个艺术家下“嵌套”创建的 Rails实际上有一个工具可以向您显示生成了哪些路由:只需运行rake routes查看一下 resource
resources :artists do
resources :users
end
全线
这将创建嵌套路由,允许您使用URL,如
/artists/5/users/45
,它将调用UsersController#show,其中参数artist\u id
为5,参数id
为45。所有其他常用的RESTful路由也都是在一个艺术家下“嵌套”创建的
Rails实际上有一个工具可以向您显示生成了哪些路由:只需运行rake routes
查看一下
resources :artists do
resources :users
end
match 'auth/:provider/callback' => 'authentications#create'
resources :authentications
devise_for :admins
match '/admin' => 'RailsAdmin/Main#index'
devise_for :users, :controllers => {:registrations => 'registrations'} do
match '/users/change_password', :to => 'registrations#change_password'
match '/users/edit_account', :to => 'registrations#edit_account'
end
resources :posts do
member do
get :likers
end
collection do
get :search
end
end
resources :relationships, :only => [:create, :destroy]
resources :appreciations, :only => [:create, :destroy]
match '/a_json/:id', :to => 'artists#index'
match '/s_json/:id', :to => 'stores#index'
match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'
match '/help', :to => 'pages#help'
match '/blog', :to => 'pages#blog'
resources :users do
member do
get :following, :followers, :likes
end
end
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
match '/:id' => 'users#show', :constraints => {:id => /[^\/]+/}, :as => :global_user
root :to => "pages#home"
end