A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.
posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord| apiVersion: v1 | |
| kind: ReplicationController | |
| metadata: | |
| name: kube-registry-v0 | |
| namespace: kube-system | |
| labels: | |
| k8s-app: kube-registry | |
| version: v0 | |
| spec: | |
| replicas: 1 |
| # 1) Create your private key | |
| $ cd ~/.ssh | |
| $ openssl genrsa -des3 -passout pass:x -out lvh.me.pass.key 2048 | |
| # 2) Generate RSA key | |
| $ openssl rsa -passin pass:x -in lvh.me.pass.key -out lvh.me.key | |
| # 3) Get rid of private key | |
| $ rm lvh.me.pass.key |
FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.
| #!/bin/bash | |
| while [[ $# -gt 1 ]] | |
| do | |
| case "$1" in | |
| -f | --file) | |
| file="$2" | |
| shift 2 | |
| ;; | |
| -h | --hostname) |
| # Wouldn't it be great if you could have STI like functionality | |
| # without needing to encode strings of class names in the database? | |
| # Well today is your lucky day! Discriminable Model is here to help. | |
| # | |
| # Simply specify your models desired type column, and provide a block to | |
| # do the discrimination. If you want the whole STI-esque shebang of properly | |
| # typed finder methods you can supply an array of 'discriminate_types' that will | |
| # be used to apply an appropriate type. | |
| # | |
| # class MyModel < ActiveRecord::Base |
This is an example of how I combine interaction/service classes with Wisper event broadcasting in Rails.
In this example, I show a UsersController#create API, a corresponding service object, and all the test code/listeners to make it all happen.
The outcome is:
object.save in dozens of places.grep for usage of it.