ActiveRecord: Retrive all records that has more/less than n characters

For example, if you want to retrieve all the records from User model that :first_name is greater than N number of characters.

You can do this:

User.where("length(first_name) > 26")  

Hopefully, this might help you out.

Victor Velazquez

Coder, Musician, Startups, Passionate Dancer & Life Lover. Director of Engineering at MagmaLabs, Co-founder of Web Dev Talks, Co-founder of Voltaire, Co-founder of Paqkit, Ex-co-founder of Zaznova.

Subscribe to The zazvick's blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!