Search code examples
ruby-on-railsrubyhstore

Ruby on Rails hstore query date greater


I am trying to query a hstore value called "date_of_birth" that is inside a column named "physical". The value is a unix time stored as a string.

dob = (Time.now - 18.years.ago)
User.where("(physical ? 'date_of_birth')::int > dob")

My code looks this.

Any help / advice would be greatly appreciated.


Solution

  • User.date_of_birth_before(Time.now-18.years)
    

    this worked for me.