Randomized Queries in Ruby on Rails
18-Nov-2018 1923
I was recently asked about options for displaying a random set of items from a table using Ruby on Rails. The request was complicated by the fact that the technology stack hadn’t been completely decided on and one of the items still up in the air was the database. I’ve had an experience with a project I was working on where the decision was made to switch from MySQL to PostgreSQL. During the switch, a sizable amount of hand constructed queries stopped functioning and had to be manually translated before they would work again. Learning from that experience, I favor avoidance of handwritten SQL in my Rails queries when possible. This precludes the option to use built-in database functions like rand() or random().
Randomized Queries in Ruby on Rails #ruby #rubydeveloper #rubyonrails #Randomized #Queries #Rails https://rubyonrails.ba/link/randomized-queries-in-ruby-on-rails