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#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c# - Making TableLayoutPanel Act Like An HTML Table (Cells That Resize Automatically Around Text) -