/ Published in: Rails

in your model, add a def
to pick a record where an option (in my case lenght) is equal to 1
to pick a record where an option (in my case lenght) is equal to 1
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def self.random ids = connection.select_all("SELECT id FROM paragraphs WHERE length = 1") find(ids[rand(ids.length)]["id"].to_i) unless ids.blank? end
Comments
