ActiveRecord select a string field has a certain length in Rails 3? -


i've got series of posts , select posts title size lesser 30, how that?

posts.where("len(title) < 30")? 

this should work:

post.where("length(title) < 30") 

you're correctly using #where shorthand :conditions in rails 3. can pass in snippet works in local sql directly.

just remember activerecord model classes singular convention.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -