LoginSignup
0
1

More than 3 years have passed since last update.

【Rails】resources_collectionの使い方

Last updated at Posted at 2020-03-07

collection

全部のデータに対するアクションに利用する。
例えばユーザーの検索機能である「serchアクション」を実装するとして、下記の様にコードを記載する。

config/routes.rb
Rails.application.routes.draw do
 resources :users do
  get :search, on: :collection
 end
end

get :search, on: :collection
上記のコードで、どのユーザから見ても全てのユーザを検索できる様になっている。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1