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")?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This should work:
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.