2011-07-28 9 views
0

このルートの仕組みを理解するのを少し助けてくれるのをお探しですか?Rails 3:このルートは何をしますか?

新ルート:

resources :artists do 
    resources :users 
end 

全体のルート

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 

答えて

1

これは、あなたが5だったパラメータartist_idとがUserControllerの#ショーを呼ぶだろう/artists/5/users/45、のようなURLを使用できるように、ネストされたルートを作成しますパラメータidは45です。他の通常のRESTfulなルートもすべて、単一のアーティストの下に「ネスト」されて作成されています。

実際には、どのルートが生成されたかを示すためのツールが用意されています。rake routesを実行すると、ピークが表示されます。

関連する問題