Red > Green > Refactor > Red

cycle is based on desire

Rails routing ; resources nesting (member|controller)

入れ子に「できる」ってのは喜ばしくも恐ろしい。用法用量との相談。

resources を nesting した中でさらに member や collection も定義できる。

Sampleapp::Application.routes.draw do
  resources :user do
    resources :session do
      get 'frequent', on: :collection
    end
  end 
end
                     Prefix Verb   URI Pattern                               Controller#Action
frequent_user_session_index GET    /user/:user_id/session/frequent(.:format) session#frequent
         user_session_index GET    /user/:user_id/session(.:format)          session#index
                            POST   /user/:user_id/session(.:format)          session#create
           new_user_session GET    /user/:user_id/session/new(.:format)      session#new
          edit_user_session GET    /user/:user_id/session/:id/edit(.:format) session#edit
               user_session GET    /user/:user_id/session/:id(.:format)      session#show
                            PATCH  /user/:user_id/session/:id(.:format)      session#update
                            PUT    /user/:user_id/session/:id(.:format)      session#update
                            DELETE /user/:user_id/session/:id(.:format)      session#destroy
                 user_index GET    /user(.:format)                           user#index
                            POST   /user(.:format)                           user#create
                   new_user GET    /user/new(.:format)                       user#new
                  edit_user GET    /user/:id/edit(.:format)                  user#edit
                       user GET    /user/:id(.:format)                       user#show
                            PATCH  /user/:id(.:format)                       user#update
                            PUT    /user/:id(.:format)                       user#update
                            DELETE /user/:id(.:format)                       user#destroy