LoginSignup
16
13

More than 5 years have passed since last update.

【RoR】where like orの書き方

Last updated at Posted at 2015-06-26
@params = '田中'

User.where("first_name LIKE :name OR last_name LIKE :name", name: "%#{@params}%") 

まあ、ファーストネームとラストネームに分けなくても方法はあると思うのですが、わかりやすいと思ったので。

※ コメントを頂いて、よりdryになりました。

16
13
2

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
16
13