ruby-on-railsrubypostgresqlahoy

where_properties function and like keyword together in ahoy


Is it possible to use LIKE keyword and where_properties function together or something similar. Because i need to create query like this.

Ahoy::Event.where(name: "$click").where_properties("'href' LIKE '%#{brochure.id}%'").count.size

Solution

  • please try this:

     Ahoy::Event.where(name: "$click").where("properties ->> :key LIKE :value", key: "href", value: "%#{brochure.id}%").size
    

    fix the query now works as expected.