I've got a series of Posts and would like to select all posts where its title size is lesser than 30, how to do that?
Posts.where("len(title) < 30")?
This should work:
Post.where("length(title) < 30")
You're correctly using #where as shorthand for :conditions in Rails 3. You can pass in any snippet that works in your local SQL directly.
Just remember that ActiveRecord model classes are singular by convention.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With