This gist will collects all issues we solved with Rails 5.2 and Webpacker
# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test| http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
| http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
| #payload: [{"kind"=>"person"}] | |
| Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
| #data: {"interest"=>["music", "movies", "programming"]} | |
| Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
| Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
| Segment.where("jsonb_array_length(data->'interest') > 1") |
This gist will collects all issues we solved with Rails 5.2 and Webpacker
# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test| { | |
| "blekinge": [ | |
| "Blekinge", | |
| { | |
| "name": "Karlshamn", | |
| "slug": "karlshamn" | |
| }, | |
| { | |
| "name": "Karlskrona", | |
| "slug": "karlskrona" |
| # assuming Model is your model and options is a json/jsonb column. | |
| # This uses the Postgres json append || operator. | |
| # And wraps the option inside an array. | |
| # producing [{},{}] multiple hashes inside a top level json array. | |
| # It is very important that the hash is [{}] NOT {} as not having the array on the | |
| # outside will cause the hash to replace the contents instead of appending to them. | |
| new_option = [{ | |
| name: option_name, |
| # This is a skeleton for testing models including examples of validations, callbacks, | |
| # scopes, instance & class methods, associations, and more. | |
| # Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
| # | |
| # I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
| # so if you have any, please share! | |
| # | |
| # @kyletcarlson | |
| # | |
| # This skeleton also assumes you're using the following gems: |
| 3294 | BabyCare Chamomile Baby wipes | 72 pcs | 2.92 | |
|---|---|---|---|---|
| 2812 | Babylino Sensitive Diapers No6 (13-18 Kg) | 40 pcs | 15.6 | |
| 3406 | Babylino Sensitive Diapers No5+ (13-27 Kg) | 42 pcs | 15.6 | |
| 3527 | Babylino Sensitive Diapers No5 (11-25 Kg) | 44 pcs | 15.6 | |
| 2602 | Babylino Sensitive Diapers No4+ (9-20 Kg) | 46 pcs | 15.6 | |
| 3699 | Babylino Sensitive Diapers No4 (7-18 Kg) | 50 pcs | 15.6 | |
| 3055 | Babylino Sensitive Pants Diapers No5 (10-16 Kg) | 46 pcs | 21.8 | |
| 3074 | Babylino Sensitive Pants Diapers No5 (10-16 Kg) | 38 pcs | 15.6 | |
| 2629 | Babylino Sensitive Pants Diapers No6 (15+ Kg) | 42 pcs | 21.8 | |
| 2896 | Babylino Sensitive Diapers No3 (4-9 Kg) | 56 pcs | 15.6 |