So you’re going to build the next-gen eCommerce company selling dog supplies and you’ve decided to use React to build it with coz, you know, its all the rage now and choosing a front-end framework is the “first and most important responsible step” towards building any successful online business.
I’d like to share a neat trick I learned while building my own eCommerce website, obviously next-gen coz React!
Filtering products based on various aspects is a staple in any shopping site and so let’s add some filters to the product results page.
As any ‘good’ React developer would, let’s break up this UI into components which is pretty straight forward in our case. …
Whenever I wanted to use placeholders in raw SQL query fragments in Rails, I would use
? and end up writing —
Post.where('published_at > ?', some_time)
What if I wanted to add another condition that checks against the same value in
Post.where('published_at > ? OR saved_at > ?', some_time, some_time)
To be perfectly honest, writing such code never bothered me and I did not put in the little effort that was needed to see if there was a better way to do this.
One day I was pairing with one of my colleagues, Preethi Kumar, and she had something that looked like symbols in her query fragments, like this —
published_at > :date . …