Prog-me.

Rails中心、機械学習も、インフラもセキュリティも

collectionとmemberのルートのちがい rails

GET /matomes/search で search アクションを呼ぶには以下のように設定する。

# config/routes.rb
resources :matomes do
  collection do
    get :search
  end
end


:id 付きのルーティングの場合はmemberを利用する。

GET /matomes/:id/preview とする場合。 

# config/routes.rb
resources :matomes do
  member do
    get :preview
  end
end

ソースは

qiita.com