LoginSignup
1
0

More than 3 years have passed since last update.

rails activerecord relationからハッシュの作り方

Posted at
Book.pluck(:id, :title)
# -> [[1, 'foo'], [2, 'bar']]

Book.pluck(:id, :title).to_h
# -> {1: 'foo', 2: 'bar'}
1
0
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
1
0