Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wrote it in SQL when I needed it, after all I knew SQL before AR came around. An OR is very rare and probably that's why it landed only in version 5.

Another implementation is Post.where(id: [1, 2]) which is SELECT * FROM posts WHERE id IN (1, 2). I guess a db would compile it into exactly the same code (dbs use different terms but that's what it is) but the performances could be different inside AR/Arel.



Post.find([1,2])

Works in Rails 4




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: