<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andy on Medium]]></title>
        <description><![CDATA[Stories by Andy on Medium]]></description>
        <link>https://medium.com/@mindovermiles262?source=rss-a5cc050838e4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2P2Pobw6vuuq-s8660798w.jpeg</url>
            <title>Stories by Andy on Medium</title>
            <link>https://medium.com/@mindovermiles262?source=rss-a5cc050838e4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 14:18:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mindovermiles262/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deploying an HTTPS Website with Kubernetes, Istio, and cert-manager: Part 2]]></title>
            <link>https://mindovermiles262.medium.com/deploying-an-https-website-with-kubernetes-istio-and-cert-manager-part-2-73951dcd0236?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/73951dcd0236</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Mon, 15 Feb 2021 19:27:13 GMT</pubDate>
            <atom:updated>2021-02-15T19:34:52.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFjSbb4s5RWDJDCKCyP7gw.png" /></figure><p>In this tutorial I’ll be walking you through you how to deploy an HTTPS microservice website using Kubernetes, Istio and Kubernetes cert-manager.</p><p>This is part 2 of a two-part series. The first part takes you through the Kubernetes cluster setup, installing and configuring Istio on that cluster, and deploying your first application on the cluster. In part 2 we’ll learn how to use Istio gateways, routes, and how to secure your website with Kubernetes cert-manager.</p><h3>Cert-Manager</h3><p>In order for our website to use HTTPS, we need to configure our Kubernetes cluster to use the cert-manager plugin. This plugin allows you to generate SSL certificates for your website automatically. To install cert-manager we&#39;ll use our Kubernetes package manager and friend Helm. Run the following 3 commands:</p><pre>$ helm repo add jetstack https://charts.jetstack.io <br>$ helm repo update <br>$ helm install cert-manager jetstack/cert-manager \<br>    --namespace istio-system \<br>    --set installCRDs=true</pre><p>When successful you’ll see a message:</p><pre>cert-manager has been deployed successfully!</pre><pre>In order to begin issuing certificates, you will need to set up a ClusterIssuer or Issuer resource (for example, by creating a &#39;letsencrypt-staging&#39; issuer).</pre><pre>More information on the different types of issuers and how to configure them can be found in our documentation:</pre><pre>https://cert-manager.io/docs/configuration/</pre><pre>For information on how to configure cert-manager to automatically provision Certificates for Ingress resources, take a look at the `ingress-shim` documentation:</pre><pre>https://cert-manager.io/docs/usage/ingress/</pre><h3>Issuer</h3><p>The cert-manager relies on a new Kubernetes api-resource called an Issuer to... well... issue certificates. It will then store the certificate inside of a Kubernetes Secret, defined in the YAML of the issuer (called my-certificate-key in this example). Be sure to update your email address</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f511bfc1a2d48479d0c147bee6bb9fb5/href">https://medium.com/media/f511bfc1a2d48479d0c147bee6bb9fb5/href</a></iframe><p>Save the YAML and apply it:</p><pre>$ kubectl apply -f my-issuer.yml </pre><pre>issuer.cert-manager.io/my-issuer created</pre><p>You can verify the certificate was created by listing the secrets in the istio-system namespace. You should see an entry for my-certificate-key:</p><pre>$ kubectl -n istio-system get secrets </pre><pre>NAME              TYPE    DATA  AGE <br>[ ... ] <br>my-certificate-key Opaque  1     5s</pre><h3>Certificates</h3><p>We’ve finally made it to where we can get our SSL certificate. To do this, we’ll create a new Certificate Kubernetes API resource. This certificate resource will, in this example, be called my-cert and live in the istio-system namespace. It will save it&#39;s certificate&#39;s .key and .crt files in a Kubernetes secret named my-ingress-cert. The issuerRef name must match the Issuer we created above, and the certificate must live in the same namespace as the istio-ingressgateway. Also don&#39;t forget to update your dnsNames.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e7de0df2127ba7f0ae31d07a838c527/href">https://medium.com/media/2e7de0df2127ba7f0ae31d07a838c527/href</a></iframe><p>Before applying your certificate YAML, double check that your domain is resolvable to your Istio Ingress Gateway IP address</p><pre>$ nslookup YOURDOMAIN.COM </pre><pre>Non-authoritative answer: <br>Name: YOURDOMAIN.COM <br>Address: 34.123.203.201</pre><p>Once confirmed, apply your certificate:</p><pre>$ kubectl apply -f my-certificate.yml </pre><pre>certificate.cert-manager.io/my-cert created</pre><p>Listing the secrets of istio-system namespace should now include the my-ingress-cert secret:</p><pre>$ kubectl get secret -n istio-system </pre><pre>NAME              TYPE                DATA  AGE <br>[ ... ] <br>my-certificate-key Opaque              1     17m <br>my-ingress-cert   kubernetes.io/tls   2     15s</pre><h3>Gateways</h3><p>With our SSL certificate in place, the last thing we need to do is route the incoming traffic to our pods. This is all done by Istio Gateways and VirtualServices. Let’s create our first Istio gateway. We’ll create a new Gateway named bookinfo-gateway-https which will reside in the default Kubernetes namespace. The gateway will listen on port 80 for YOURDOMAIN.COM and redirect traffic to HTTPS Port 443. The gateway will also be listening on HTTPS/443 for YOURDOMAIN.COM and use the certificate we created in the previous step, my-ingress-cert</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba5df725df840fff4770715f62d5550e/href">https://medium.com/media/ba5df725df840fff4770715f62d5550e/href</a></iframe><p>Apply the gateway YAML file:</p><pre>$ kubectl apply -f my-gateway.yml </pre><pre>gateway.networking.istio.io/bookinfo-gateway-https created</pre><h3>Virtual Services</h3><p>The last component of this that we need to set up are the Virtual Services. Similar to those in NGINX or Apache, we need to configure the routes that Istio will direct traffic that comes in on YOURDOMAIN.COM to. These routes are called &quot;Virtual Services&quot; and are defined by yet another YAML file. The virtual service will route all requests to /productpage, /static, /login, /logout, and /api/v1/products through the bookinfo-gateway-https gateway we created above and route it to the productpage service of the application. This productpage service was created when we deployed the bookinfo application in part 1 of this tutorial.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eef64b3aa12b9848c1ffb8b7c8ded926/href">https://medium.com/media/eef64b3aa12b9848c1ffb8b7c8ded926/href</a></iframe><p>Apply your virtual services:</p><pre>$ kubectl apply -f my-virtualservice.yml </pre><pre>virtualservice.networking.istio.io/bookinfo-virtualservice created</pre><p>Hooray! You’ve done it! You should be able to go to https://YOURDOMAIN.COM/productpage and see the beautiful bookinfo example application deployed!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73951dcd0236" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying an HTTPS Website with Kubernetes, Istio, and cert-manager: Part 1]]></title>
            <link>https://mindovermiles262.medium.com/deploying-an-https-website-with-kubernetes-istio-and-cert-manager-part-1-c5b5e5e44b24?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5b5e5e44b24</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Mon, 15 Feb 2021 19:11:16 GMT</pubDate>
            <atom:updated>2021-02-15T19:31:58.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFjSbb4s5RWDJDCKCyP7gw.png" /></figure><p>In this tutorial I’ll be walking you through you how to deploy an HTTPS microservice website using Kubernetes, Istio and Kubernetes cert-manager.</p><p>This is part 1 of a two-part series. The first part takes you through the Kubernetes cluster setup, installing and configuring Istio on that cluster, and deploying your first application on the cluster. In part 2 we’ll learn how to use Istio gateways, routes, and how to secure your website with Kubernetes cert-manager.</p><h3>Kubernetes</h3><p>Kubernetes is a program that makes multi-cluster deployments easy. It provides easy HA and redundancy. It’s the backbone of everything else here. In Kubernetes you’ll deploy “pods” which contain all the containers necessary to run the application or microservice.</p><h3>Istio</h3><p>Istio is a plugin to Kubernetes that makes networking simple. It provides a lot of features out of the box and is very simple to use and configure. When you install Istio, you’ll create a bunch of custom Kubernetes resources via “Custom Resource Definitions (CRD)”. More on this later.</p><h3>Cert-Manager</h3><p>Cert-Manager is another plugin for Kubernetes that automates the SSL/TLS certificate issuance process. Similar to Istio, it’s a CRD and we’ll discuss more about it later.</p><p>This tutorial assumes you already have kubectl installed on your local computer. If you do not, please follow <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/">these</a> directions to install kubectl.</p><h3>Getting Started</h3><p>The first step to deploying a website is spinning up a Kubernetes cluster. In this tutorial we’ll be using Google Cloud Platform (GCP). First, download the google-cloud-sdk which will give you command line access to Google Cloud. Download it <a href="https://cloud.google.com/sdk/docs/quickstart">here</a>.</p><p>Once installed, you’ll need to authenticate to your GCP account by running gcloud init and running through the setup process.</p><h3>Your first cluster</h3><p>To create your first Kubernetes cluster, simply run the following command in your terminal:</p><pre>gcloud container clusters create &quot;my-istio-https-cluster&quot; \ <br>  --zone &quot;us-central1-c&quot; \ <br>  --num-nodes &quot;3&quot;</pre><p>NOTE: If you receive an “ERROR: (gcloud.container.clusters.create) … should enable service:container.googleapis.com before generating a service account.” — You’ll need to log into the Google Cloud Console and enable the Kubernetes API for your project.</p><p>You should see some confirmation that your cluster is being created. This might take a few minutes.</p><pre>$ gcloud container clusters create &quot;my-istio-https-cluster&quot; \ <br>  --zone &quot;us-central1-c&quot; \<br>  --num-nodes &quot;3&quot; </pre><pre>Creating cluster my-istio-https-cluster in us-central1-c... <br>Cluster is being deployed... <br>Cluster is being health-checked... <br>Created [https://container.googleapis.com/v1/projects/my-istio-https-project/zones/us-central1-c/clusters/my-istio-https-cluster]. <br>To inspect the contents of your cluster, go to: https://console.cloud.google.com/kubernetes/workload_/gcloud/us-central1-c/my-istio-https-cluster?project=my-istio-https-project <br>kubeconfig entry generated for my-istio-https-cluster.</pre><p>Confirm you’ve set up your cluster by running the following command from your local terminal:</p><pre>$ kubectl get pods --all-namespaces</pre><p>You should see a bunch of kube-system pods running on the cluster.</p><h3>Installing Istio on the cluster</h3><p>Next, we need to install Istio to both your local computer and to the freshly created cluster. To do this, we’ll use helm. Helm is a package manager for Kubernetes - which means that you can run one simple command and Helm will install all the necessary Kubernetes resources for you.</p><p>First, download and install the helm binary for your system. Instructions <a href="https://helm.sh/docs/intro/install/">here</a></p><p>While you’re downloading things, make sure to download and install Istio too. Instructions <a href="https://istio.io/latest/docs/setup/getting-started/#download">here</a> (Just the “Download Istio” instructions for now!)</p><p>With Helm and Istio installed on your local computer, installing Istio to the cluster is as simple as running the following command:</p><pre>$ istioctl install --set profile=demo</pre><p>Be sure to use the demo profile otherwise Istio will not install due to pod system limitations.</p><pre>$ istioctl install --set profile=demo </pre><pre>✔ Istio core installed <br>✔ Istiod installed <br>✔ Egress gateways installed <br>✔ Ingress gateways installed <br>✔ Installation complete</pre><p>Now, if you check the pods of the istio-system namespace, you&#39;ll see Istio has been installed</p><pre>$ kubectl get pods -n istio-system<br><br>NAME  READY   STATUS    RESTARTS   AGE<br>istio-egressgateway-cd6b59579-mfkcd     1/1     Running<br>istio-ingressgateway-78f7794d66-sqttw   1/1     Running<br>istiod-574485bfdc-c9bkm                 1/1     Running</pre><p>There is one last gotcha that we need to take care of. Behind the scenes, Istio uses Envoy to route traffic. An Envoy container needs to be included with each of the pods that are deployed. To enable this, simply run the following command:</p><pre>$ kubectl label namespace default istio-injection=enabled</pre><h3>Deploying your Application</h3><p>In this demo, we’re going to be deploying the demo Bookinfo Application provided by Istio. This is a microservice application that shows off Istio’s ability to connect various services of an application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1kXaDJ_bKL-HRA_J3FIcpA.png" /><figcaption>Source: https://istio.io</figcaption></figure><p>To deploy this application, simply run</p><pre>kubectl apply -f <a href="https://raw.githubusercontent.com/istio/istio/release-1.9/samples/bookinfo/platform/kube/bookinfo.yaml">https://raw.githubusercontent.com/istio/istio/release-1.9/samples/bookinfo/platform/kube/bookinfo.yaml</a></pre><p>This will pull the chart from Istio’s Github and create a bunch of new Kubernetes services, service accounts, and deployments</p><pre>$ kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.9/samples/bookinfo/platform/kube/bookinfo.yaml </pre><pre>service/details created serviceaccount/bookinfo-details created <br>deployment.apps/details-v1 created service/ratings created <br>serviceaccount/bookinfo-ratings created deployment.apps/ratings-v1 <br>created service/reviews created serviceaccount/bookinfo-reviews created <br>deployment.apps/reviews-v1 created deployment.apps/reviews-v2 created <br>deployment.apps/reviews-v3 created service/productpage created <br>serviceaccount/bookinfo-productpage created <br>deployment.apps/productpage-v1 created</pre><p>Confirm your pods are up and running ( Ready: 2/2) by running the kubectl get pods command:</p><pre>$ kubectl get pods </pre><pre>NAME READY STATUS RESTARTS AGE <br>details-v1-5f449bdbb9-gfccz     2/2 Running 0 51s <br>productpage-v1-6f9df695b7-w7dq6 2/2 Running 0 50s <br>ratings-v1-857bb87c57-sltxd     2/2 Running 0 50s <br>reviews-v1-68f9c47f69-n6m2d     2/2 Running 0 50s <br>reviews-v2-5d56c488f5-tzgv7     2/2 Running 0 50s <br>reviews-v3-869ff44845-9h4mc     2/2 Running 0 50s</pre><h3>DNS</h3><p>Before we end this part of the tutorial and get into Istio routing and gateways, we need to update our DNS records so that we can get a valid certificate later. You’ll need to provide an IP address to your DNS registrar to properly route your domain name to your istio-ingressgateway load balancer. You can get that address by running the following command and grabbing the EXTERNAL-IP address of the istio-ingressgateway:</p><pre>$ kubectl get svc -n istio-system </pre><pre>NAME                 TYPE         CLUSTER-IP    EXTERNAL-IP <br>istio-egressgateway  ClusterIP    10.7.254.232  &lt;none&gt; <br>istio-ingressgateway LoadBalancer 10.7.248.101  34.123.203.201 <br>istiod               ClusterIP    10.7.250.247  &lt;none&gt;</pre><p>Then you’ll need to log into your DNS registrar website, and create a new A Record, pointing your domain to the external IP address listed above.</p><h3>Conclusion</h3><p>Well done! You’ve made it through the most difficult parts of this tutorial. The DNS propagation will take a few minutes to complete so feel free to step away, grab another cup of coffee and come back for Part 2 in a few minutes!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5b5e5e44b24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Sense of Apple’s Notarization]]></title>
            <link>https://mindovermiles262.medium.com/making-sense-of-apples-notarization-4571af960976?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4571af960976</guid>
            <category><![CDATA[catalina]]></category>
            <category><![CDATA[notarization]]></category>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Wed, 24 Jul 2019 18:35:33 GMT</pubDate>
            <atom:updated>2019-07-25T23:47:42.381Z</atom:updated>
            <content:encoded><![CDATA[<p>A few weeks ago, Apple announced MacOS 10.15 — Catalina. Along with this they also introduced a requirement to sign and notarize all .pkg .dmg, kexts, and Applications.</p><blockquote>Mac apps, installer packages, and kernel extensions that are signed with Developer ID must also be notarized by Apple in order to run on macOS Catalina. This will help give users more confidence that the software they download and run, no matter where they get it from, is not malware by showing a more streamlined Gatekeeper interface.</blockquote><p><a href="https://developer.apple.com/news/?id=06032019i">Source</a></p><p>So what does this mean for us Mac SysAdmins? It means we’re going to have to do a lot of work pushing companies to get their shit together.</p><h3>Checking existing software for compatibility</h3><p>We can easily determine if a pkg will run on catalina using existing tools. Be sure to have XCode installed before running these checks</p><h4>PKGs</h4><pre><br>$ pkgutil --check-signature &lt;path to pkg&gt;</pre><pre>$ pkgutil --check-signature 1Password-7.3.1.pkg</pre><pre>Package “1Password-7.3.1.pkg”:<br> Status: signed by a certificate trusted by Mac OS X<br> Certificate Chain:<br> 1. Developer ID Installer: AgileBits Inc. (2BUA8C4S2C)<br> SHA1 fingerprint: 3F F5 AB E5 D3 F8 3D FD 81 57 C8 6A 30 19 C7 73 99 BA 0D 25<br> — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -<br> 2. Developer ID Certification Authority<br> SHA1 fingerprint: 3B 16 6C 3B 7D C4 B7 51 C9 FE 2A FA B9 13 56 41 E3 88 E1 86<br> — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -<br> 3. Apple Root CA<br> SHA1 fingerprint: 61 1E 5B 66 2C 59 3A 08 FF 58 D1 4A E2 24 52 D1 98 DF 6C 60</pre><p>This package has been signed by AgileBits Inc. Because it’s been signed, it must also now be notarized to work on MacOS Catalina. We can check the notarization of an app with</p><pre>$ stapler validate &lt;path to pkg&gt;</pre><pre>$ stapler validate 1Password-7.3.1.pkg</pre><pre>Processing: /Users/aduss/Downloads/1Password-7.3.1.pkg<br>The validate action worked!</pre><p>It works! This pkg has been signed and notarized. It will work on Catalina:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T4reMiZ4i-nVx2zNpbLj5w.png" /></figure><h4>DMGs</h4><p>DMGs can also be checked to see if they will work on Catalina. The same process applies, but with slightly different commands. We first need to check that the DMG is signed, and then check that it’s been notarized.</p><pre>$ spctl -a -t open --context context:primary-signature -v &lt;path to dmg&gt;</pre><pre>$ spctl -a -t open --context context:primary-signature -v Dropbox-76.4.126.dmg</pre><pre>./Dropbox-76.4.126.dmg: accepted<br>source=Developer ID</pre><p>This Dropbox dmg has been signed. Let’s see if it’s notarized. We can use the stapler validate command again to check.</p><pre>$ stapler validate &lt;path to dmg&gt;</pre><pre>$ stapler validate Dropbox-76.4.126.dmg</pre><pre>Processing: Dropbox-76.4.126.dmg<br>Dropbox-76.4.126.dmg does not have a ticket stapled to it.</pre><p>No ticket = Not Notarized. Dropbox 76.4.126 will not work on Catalina</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h9gRXWTdSiFC8HugMq6sUg.png" /></figure><h4>Applications</h4><p>In general, Applications must be signed before they can be installed onto your mac. But if you’re using an old version of MacOS or just want to verify, you can use the codesign command in your terminal</p><pre>$ codesign -dv &lt;Path to App&gt;</pre><pre>$ codesign -dv /Applications/Spotify.app/</pre><pre>Executable=/Applications/Spotify.app/Contents/MacOS/Spotify<br> [ .. snip .. ]<br>Signature size=9046<br> [ .. snip .. ]</pre><p>This Spotify app is signed. Let’s see if it’s notarized</p><pre>$ stapler validate &lt;Path to App&gt;</pre><pre>$ stapler validate /Applications/Spotify.app</pre><pre>Processing: /Applications/Spotify.app<br>Spotify.app does not have a ticket stapled to it.</pre><p>Womp Womp =( Spotify is not notarized. It does not work on Catalina.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mYw_CgpCTh_rJFzG0AB7zA.png" /></figure><h3>So how can we fix this?</h3><p>Unfortunately, there is little we can do as consumers of applications. If we don’t own the code, we can’t notarize it. Reach out to the support teams of the software you’re trying to install and tell them their product doesn’t work on MacOS 10.15 Catalina.</p><p>If you do own the code, you’ll need to notarize your application. Apple has created a great guide on how notarize your application so it can work on 10.15. Feel free to <a href="https://developer.apple.com/documentation/security/notarizing_your_app_before_distribution">read this article</a> to get started.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4571af960976" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Triple Nested Forms in Rails]]></title>
            <link>https://mindovermiles262.medium.com/triple-nested-forms-in-rails-dedbcccb5799?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/dedbcccb5799</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[nest]]></category>
            <category><![CDATA[forms]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Tue, 05 Sep 2017 17:13:58 GMT</pubDate>
            <atom:updated>2017-09-05T17:15:11.474Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*iMQDd86ExrlfZIWrGGvk4A.jpeg" /></figure><p>There are countless videos out there showing you how to make a single nested form. That is, a form that accepts two models. This tutorial is different in that it shows you how to make a 3+ nested form. Let’s get started.</p><p>First, we’ll make a new rails app, $ rails new nested-forms and enter into the directory.</p><p>For this tutorial, we are going to use three models, show, season, and episode. Each show has many seasons which have many episodes</p><p>Let’s generate the first show model,</p><pre>nested-forms $ rails g scaffold show name:string</pre><p>then our second model, season</p><pre>nested-forms $ rails g model season number:integer show:references</pre><p>Note how we include a reference to show, it will be included in our migrations.</p><p>Now let’s edit our models to apply the associations:</p><pre># models/show.rb<br>class Show &lt; ApplicationRecord<br>  has_many :seasons<br>  accepts_nested_attributes_for :seasons<br>end</pre><pre># models/season.rb<br>class Season &lt; ApplicationRecord<br>  belongs_to :show, optional: true<br>end</pre><p>and then add to our controller:</p><pre># controllers/shows_controller.rb<br>def new<br>  @show = Show.new<br>  @show.seasons.build<br>end</pre><pre>...</pre><pre>private<br>def show_params<br>  params.require(:show).permit(:name, <br>    :seasons_attributes =&gt; [:number]<br>  )<br>end</pre><p>and finally, let’s update our form to render these fields:</p><pre>&lt;%= form_with(model: show, local: true) do |form| %&gt;</pre><pre>  # Show name and label</pre><pre>  &lt;%= form.fields_for :seasons do |s| %&gt;<br>    &lt;%= s.label :number %&gt;<br>    &lt;%= s.number_field :number %&gt;<br>  &lt;% end %&gt;</pre><pre>  # Submit Button</pre><pre>&lt;% end %&gt;</pre><p>Notice how we chain fields_for onto form and then pass our new variable s into the block. This is what creates the association.</p><p>We’ve now completed our first nest. Try it out. Fire up the server, go to /shows/new and create a new show with a title and number (the number won’t show up after creation because we haven’t added it to the show view)</p><p><strong>Triple Nesting</strong></p><p>Now the fun begins. Triple nesting.</p><p>Let’s create a new model:</p><pre>nested-forms $ rails g model episode title:string season:references</pre><p>Similar to to how seasons referenced show, our new model references seasons.</p><p>To get the tri-nested form inside the nested form, we basically have to repeat the procedure as above, but this time inside of season</p><p>First, we edit the models:</p><pre># models/season.rb<br>class Season &lt; ApplicationRecord<br>  belongs_to :show, optional: true<br>  has_many :episodes<br>  accepts_nested_attributes_for :episodes<br>end</pre><pre># models/episode.rb<br>class Episode &lt; ApplicationRecord<br>  belongs_to :season, optional: true<br>end</pre><p>then edit the shows_controller to accept further nested attributes:</p><pre># controllers/shows_controller.rb<br>  def new<br>    @show = Show.new<br>    @show.seasons.build.episodes.build<br>  end</pre><pre>private</pre><pre>  def show_params<br>    params.require(:show).permit(:name, <br>      :seasons_attributes =&gt; [:number,<br>        :episodes_attributes =&gt; [:title]<br>      ]<br>    )<br>  end</pre><p>and then, finally, the form:</p><pre>&lt;%= form_with(model: show, local: true) do |form| %&gt;</pre><pre># Show name and label</pre><pre>  &lt;%= form.fields_for :seasons do |s| %&gt;<br>    &lt;%= s.label :number %&gt;<br>    &lt;%= s.number_field :number %&gt;</pre><pre>    &lt;%= s.fields_for :episodes do |e| %&gt;<br>      &lt;%= e.label :title %&gt;<br>      &lt;%= e.text_field :title %&gt;<br>    &lt;% end %&gt;</pre><pre>  &lt;% end %&gt;</pre><pre># Submit Button</pre><pre>&lt;% end %&gt;</pre><p>Notice how the episodes fields for is nested inside of the seasons fields for. We use the symbol from the seasons to create the fields for episodes.</p><p>Now, migrate the changes. When you fire up the server and go to /shows/new you should see three fields, a show, a number, and a title. Try submitting a new record and examine it in rails console and you should see that it is accepting all records.</p><p>To keep nesting, just repeat the above instructions again until you pass out.</p><p><strong>Conclusion</strong></p><p>I hope that you find this article useful for developing rails applications. If you have any questions or comments feel free to leave a comment below, or tweet at me: @mindovermiles26</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dedbcccb5799" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with RSpec — Part 2]]></title>
            <link>https://mindovermiles262.medium.com/getting-started-with-rspec-part-2-acb9f5b133c6?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/acb9f5b133c6</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[test-driven-development]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[rspec]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Fri, 01 Sep 2017 05:42:39 GMT</pubDate>
            <atom:updated>2018-06-19T15:19:52.185Z</atom:updated>
            <content:encoded><![CDATA[<p>Note: This is the second and final installment of the RSpec — Getting Started series. If you haven’t read the first part, please go back (<a href="https://medium.com/@mindovermiles262/getting-started-with-rspec-part-1-9418909f5e53">link</a>) and read it before continuing.</p><p>In the previous edition of “Getting Started with RSpec” we made a simple calculator with unit tests. We saw how tests can help us maintain code even when working with pretty dumb programmers.</p><p>In this installment we are going to be focusing on Test Driven Development (TDD). What is TTD?</p><blockquote>Test Driven Development is the workflow of writing a test, letting it fail, and then changing your code to make it (and all the previous tests) pass.</blockquote><p>Enough talk, let’s get coding</p><p>To demonstrate let’s add a subtract method to our calculator. To do this following a TDD workflow, we first add a test with our expectations:</p><pre># File: spec/calculator_spec.rb</pre><pre>require &#39;./calculator.rb&#39;</pre><pre>describe &quot;calculator&quot; do</pre><pre>it &#39;adds numbers&#39; do<br>    ...<br>  end</pre><pre>it &#39;subtracts numbers&#39; do<br>    calc = Calculator.new<br>    expect(calc.subract(5,1)).to eql(4)<br>  end</pre><pre>end</pre><p>This new subtracts numbers test is expecting that when we call the subtract function and pass it two parameters, 5 and 1 we will be returned a value of 4</p><p>Let’s run the tests to make sure we don’t have any syntax errors:</p><pre>calculator $ bundle exec rspec<br>.F</pre><pre>Failures:</pre><pre>1) calculator subtracts numbers<br>     Failure/Error: expect(calc.subtract(5,1)).to eql(4)<br>     <br>     NoMethodError:<br>       undefined method `subtract&#39; for #&lt;Calculator:0x007f9dc4a65f40&gt;<br>     # ./spec/calculator_spec.rb:11:in `block (2 levels) in &lt;top (required)&gt;&#39;</pre><pre>Finished in 0.00236 seconds (files took 0.08835 seconds to load)<br>2 examples, 1 failure</pre><pre>Failed examples:</pre><pre>rspec ./spec/calculator_spec.rb:9 # calculator subtracts numbers</pre><p>Just what we expected. One of our tests has failed. We can see which test has failed in the last line of the output.</p><p>Now that we have written our test and have seen it fail, it’s time to make it pass.</p><p>Let’s create a subtract method in our Calculator:</p><pre># File: calculator.rb</pre><pre>class Calculator<br>  def add(x, y)<br>    x + y<br>  end<br>  <br>  def subtract(x, y)<br>    x - y<br>  end<br>end</pre><p>The last step in TDD is to make all the tests pass. This is sometimes called going “Green,” since the output of passing tests is green. To see if our Calculator behaves as we want it to, run the tests:</p><pre>calculator $ rspec<br>..</pre><pre>Finished in 0.00224 seconds (files took 0.08993 seconds to load)<br>2 examples, 0 failures</pre><p>Perfect! You’ve just completed your first TDD cycle! That wasn’t too difficult, was it?</p><p>Now that you’re feeling confidant in your abilities, let’s repeat this process for themultiply and divide functions. Let’s start with multiply :</p><pre># File: spec/calculator_spec.rb</pre><pre>require &#39;./calculator.rb&#39;</pre><pre>describe &#39;calculator&#39; do<br>  it &#39;adds numbers&#39; do<br>    ...<br>  end</pre><pre>it &#39;subtracts numbers&#39; do<br>    ...<br>  end</pre><pre>it &#39;multiplies numbers&#39; do<br>    calc = Calculator.new<br>    expect(calc.multiply(3,4)).to eql(12)<br>  end</pre><pre>end</pre><p>Make sure your tests fail by running rspec</p><p>Then change your code so your tests pass:</p><pre># File: calculator.rb</pre><pre>class Calculator<br>  def add(x, y)<br>    x + y<br>  end</pre><pre>def subtract(x, y)<br>    x - y<br>  end</pre><pre>def multiply(x, y)<br>    x*y<br>  end</pre><pre>end</pre><p>Do your tests now pass?</p><pre>calculator $ rspec<br>...</pre><pre>Finished in 0.00262 seconds (files took 0.08638 seconds to load)<br>3 examples, 0 failures</pre><p>Lookin’ good! Lastly let’s finish with our divide function:</p><pre># File: spec/calculator_spec.rb</pre><pre>require &#39;./calculator.rb&#39;</pre><pre>describe &#39;calculator&#39; do<br>  it &#39;adds numbers&#39; do<br>    ...<br>  end</pre><pre>it &#39;subtracts numbers&#39; do<br>    ...<br>  end</pre><pre>it &#39;multiplies numbers&#39; do<br>    ...<br>  end</pre><pre>it &#39;divides numbers&#39; do<br>    calc = Calculator.new<br>    expect(calc.divide(5,2)).to eql(2.5)<br>  end</pre><pre>end</pre><p>Watch your test fail and then add the divide method:</p><pre># File: calculator.rb</pre><pre>class Calculator<br>  def add(x, y)<br>    x + y<br>  end</pre><pre>def subtract(x, y)<br>    x - y<br>  end</pre><pre>def multiply(x, y)<br>    x*y<br>  end</pre><pre>def divide(x, y)<br>    x / y<br>  end<br>end</pre><p>One final check gives us:</p><pre>calculator $ rspec<br>...F</pre><pre>Failures:</pre><pre>1) calculator divides numbers<br>     Failure/Error: expect(calc.divide(5,2)).to eql(2.5)<br>     <br>     NoMethodError:<br>       undefined method `divide&#39; for #&lt;Calculator:0x007fc9c0345440&gt;<br>     # ./spec/calculator_spec.rb:23:in `block (2 levels) in &lt;top (required)&gt;&#39;</pre><pre>Finished in 0.00278 seconds (files took 0.09446 seconds to load)<br>4 examples, 1 failure</pre><pre>Failed examples:</pre><pre>rspec ./spec/calculator_spec.rb:21 # calculator divides numbers</pre><p>Whoops! That’s clearly not right. We were expecting all our tests to pass. What’s going on here?</p><p>To get more information about the error, we can add a handy feature of RSpec, output formatting. In the console run the command rspec --format documentation and you should get this:</p><pre>calculator $ rspec<br>...F</pre><pre>Failures:</pre><pre>1) calculator divides numbers<br>     Failure/Error: expect(calc.divide(5,2)).to eql(2.5)<br>     <br>       expected: 2.5<br>            got: 2<br>     <br>       (compared using eql?)<br>     # ./spec/calculator_spec.rb:23:in `block (2 levels) in &lt;top (required)&gt;&#39;</pre><pre>Finished in 0.01352 seconds (files took 0.09081 seconds to load)<br>4 examples, 1 failure</pre><pre>Failed examples:</pre><pre>rspec ./spec/calculator_spec.rb:21 # calculator divides numbers</pre><p>We were expecting the value 2.5 to be returned, but instead we received a value of 2</p><p>This is where TDD really shines bright. If we hadn’t had these tests in place, we would have been in trouble when we needed to use the divide function in production.</p><p>To fix this problem, we need to change one the divde inputs to Float with the .to_f function:</p><pre>def divide(x, y)<br>  x / y.to_f<br>end</pre><p>Now that we’ve made a change, we rerun the tests:</p><pre>calculator $ rspec<br>....</pre><pre>Finished in 0.00271 seconds (files took 0.09715 seconds to load)<br>4 examples, 0 failures</pre><p>That’s better. Now that all of our tests are passing, we can call it a day. Great work!</p><p>Test Driven Development is an important tool in any developer’s toolbox. It allows us to develop with the confidence that our code is not going to break if we change something. It’s especially helpful when refactoring our code to ensure that all the functions work properly. Refactoring is almost impossible without test to back it up. If you have any questions about TDD please feel free to leave a comment below</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acb9f5b133c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with RSpec — Part 1]]></title>
            <link>https://mindovermiles262.medium.com/getting-started-with-rspec-part-1-9418909f5e53?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9418909f5e53</guid>
            <category><![CDATA[rspec]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[tdd]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Sun, 27 Aug 2017 06:27:00 GMT</pubDate>
            <atom:updated>2017-08-27T15:19:38.229Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Note</strong>: This is the first post of the Getting Started with RSpec tutorial. This tutorial is designed for novice Ruby programmers wanting to learn how to add automatic testing to their apps.</p><p><strong>TLDR</strong>: RSpec is a way of ensuring that your app does what you want it to do.</p><p>There are a few things that help good programmers become great programmers. Writing unit tests to ensure code stability is one of these attributes.</p><p>RSpec is an automated testing framework for Ruby. Testing frameworks are used by a developers to create tests for actions, functions, or methods in their program ensuring that the code runs properly. You can think of RSpec tests as any exam in a high school class. There is a baseline requirement (“C” Grade, for example) for someone to pass the class. RSpec tests ensure that your code passes the class with a C or better.</p><p>Testing is highly important and you can bet that any developer worth their salt knows how to write tests. The first step to using RSpec is to install it.</p><p><strong>INSTALLING RSpec</strong></p><p>RSpec can be installed via a Ruby Gem.</p><blockquote>Gems are Ruby libraries developed by other programmers that quickly add functionality to a program. Gems are primarily used with Ruby on Rails applications, so if you get a little lost it’s okay. Just try to follow along.</blockquote><p>To install a gem, we first need to make a Gemfile. A Gemfile is file that contains instructions on which gems to install. Inside of a Gemfile there are three pieces of information: a gem source, a list of gems, and their version numbers.</p><p>Let’s get started by creating a new folder called calculator and cd-ing into it inside of your terminal. Inside of this folder, make a new file namedGemfile (note the capital G and no extension) by running the command touch Gemfile . Open Gemfile with your text editor and add the following:</p><pre># calculator/Gemfile<br>source “<a href="https://rubygems.org/">https://rubygems.org</a>&quot;</pre><pre>gem ‘rspec’, ‘~&gt; 3.6’</pre><p>as you probably guessed, the source line tells the installer where to find the gem, and the gem line tells the installer which gem and version to install. The ~&gt; symbol (formally called the “Approximately greater than” symbol) tells the installer to install any version greater than 3.6 but less than 4.0. Confusing, but let’s roll with it.</p><p>Now that we have our Gemfile set up, we will run the installer. From your terminal (still in the calculator directory), run the command bundle install</p><p>This will install the RSpec gem:</p><pre>calculator $ bundle install<br>Fetching gem metadata from <a href="https://rubygems.org/">https://rubygems.org/</a>..........<br>Fetching version metadata from <a href="https://rubygems.org/">https://rubygems.org/</a>.<br>Resolving dependencies…<br>Using bundler 1.15.3<br>Using diff-lcs 1.3<br>Using rspec-support 3.6.0<br>Using rspec-core 3.6.0<br>Using rspec-expectations 3.6.0<br>Using rspec-mocks 3.6.0<br>Fetching rspec 3.6.0<br>Installing rspec 3.6.0<br>Bundle complete! 1 Gemfile dependency, 7 gems now installed.<br>Use `bundle info [gemname]` to see where a bundled gem is installed.</pre><p><strong>BOOM!</strong> RSpec is now installed!</p><p><strong>WRITING AN EXAMPLE PROGRAM</strong></p><p>The easiest way to explain how RSpec and, later, Test Driven Development (TDD) works is by creating an example. Let’s write a calculator program that will add two numbers.</p><p>Create a file, calculator.rb by typing touch calculator.rb in your terminal window (still inside your calculator directory). Then, open the file in your text editor and write the program:</p><pre># calculator.rb<br>class Calculator<br>  def add(x, y)<br>    x + y<br>  end<br>end</pre><p>Then load it into irb to make sure it works:</p><pre>calculator $ irb</pre><pre>: 001 &gt; load ‘./calculator.rb’<br> =&gt; true</pre><pre>: 002 &gt; calc = Calculator.new<br> =&gt; #&lt; Calculator:0x007f9ea882cb40&gt;</pre><pre>:003 &gt; calc.add(2, 3)<br> =&gt; 5</pre><p>Looks like it’s working! We expect the function add(2, 3) to equal 5 (and it does).</p><p>Now that we have a something to test, let’s write some tests to make sure it keeps working the way we want it to.</p><p>RSpec tests are named after the file they test. For our calculator.rb file, we will be creating a new file, calculator_spec.rb where all the tests will be written. All *_spec.rb files should be kept organized inside a spec folder. To make that folder, enter mkdir spec in your terminal, then create the calculator_spec.rb file by entering touch spec/calculator_spec.rb .</p><p>You’re all set to write your first RSpec test!</p><p><strong>WRITING OUR FIRST TEST</strong></p><p>Now that we’re all set up, it’s time to write the first test. Open the calculator_spec.rb file in your text editor and add the line:</p><pre>require ‘./calculator.rb’</pre><p>This line tells RSpec where to find the calculator program we wrote before.</p><p>At it’s core, RSpec describes how we want our program to behave. It’s syntax (a.k.a. Domain Specific Syntax) is meant to be fairly easy to read and figure out what’s going on. We’ll start off by describing the way we want the calculator to behave.</p><pre>require ‘./calculator.rb’</pre><pre>describe “calculator” do<br> it “adds numbers”<br>end</pre><p>Just by reading this out loud you should be able tell what we will be testing. We will now run RSpec to make sure we have everything set up properly. From your terminal enter:</p><pre>calculator $ rspec</pre><p>and you should get an output similar to:</p><pre><br>calculator $ rspec<br>*</pre><pre>Pending: (Failures listed here are expected and do not affect your suite’s status)</pre><pre>1) calculator adds numbers<br> # Not yet implemented<br> # ./spec/calculator_spec.rb:4</pre><pre>Finished in 0.00172 seconds (files took 0.08711 seconds to load)<br>1 example, 0 failures, 1 pending</pre><p>Everything is working. The test is pending since we have told RSpec that we will be testing the addition feature, but haven’t actually implemented the test yet. This is the last thing we will do.</p><pre><br>require ‘./calculator.rb’</pre><pre>describe “calculator” do<br> it “adds numbers” do<br>   calc = Calculator.new<br>   expect(calc.add(2, 3)).to eql(5)<br> end<br>end</pre><p>Similar to how we tested out the program in irb we expect the calculator add function to equal 5 when we add 2 and 3 together.</p><p>Now if we re-run RSpec we will see that the pending test has “turned green” and passed</p><pre>calculator $ rspec<br>.</pre><pre>Finished in 0.00523 seconds (files took 0.08796 seconds to load)<br>  1 example, 0 failures</pre><p><strong>TAADAA! </strong>You’ve just written your first RSpec test!</p><p><strong>WHY IS TESTING IMPORTANT?</strong></p><p>It’s common for many developers to be working on the same application. Writing tests ensures that the feature you’ve written performs as it should each and every time.</p><p>Take for example your coworker Matz, a developer who’s not so sharp. He is reading through your calculator code and he sees the add function and says to himself, “a.d.d. stands for Attention Deficit Disorder, not this weird x + y stuff”, so he refactors your code returning the string “ADD” instead of the sum of the two numbers.</p><pre># calculator.rb<br>class Calculator<br> def add(x, y)<br> “ADD”<br> end<br>end</pre><p>But this isn’t what you intended your code to do, so when you run RSpec you get an error:</p><pre><br>calculator $ rspec<br>F</pre><pre>Failures:<br> 1) calculator adds numbers<br> Failure/Error: expect(calc.add(2, 3)).to eql(5)<br> <br> expected: 5<br> got: “ADD”<br> <br> (compared using eql?)<br> # ./spec/calculator_spec.rb:6:in `block (2 levels) in &lt;top (required)&gt;’</pre><pre>Finished in 0.01897 seconds (files took 0.09196 seconds to load)<br>1 example, 1 failure</pre><pre>Failed examples:</pre><pre>rspec ./spec/calculator_spec.rb:4 # calculator adds numbers</pre><p>Your RSpec test has caught the error. It expecting calc.add(2, 3) to equal 5, but getting the string “ADD” back instead</p><p><strong>CONCLUSION</strong></p><p>Although this first test may seem trivial, testing is an important component of any application. This tutorial is designed to show you the basics of testing with RSpec and getting you started. Large applications have thousands of tests to make sure each component is working correctly. As you write more and more tests you’ll realize the importance of them. Writing one good test can save you many hours in the long run by preventing you from hunting down a bug.</p><p>Please tune in later for the next installment of the Getting Started with RSpec tutorial where we will talk about Test Driven Development (TDD). If you have any questions please feel free to contact me by leaving a comment below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9418909f5e53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PostgreSQL Foreign Keys and References]]></title>
            <link>https://mindovermiles262.medium.com/postgresql-foreign-keys-and-reference-ab582a62c7b9?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab582a62c7b9</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Wed, 26 Jul 2017 17:17:09 GMT</pubDate>
            <atom:updated>2017-07-26T17:17:23.457Z</atom:updated>
            <content:encoded><![CDATA[<p>Few things in the world are more frustrating to a developer as when you push your code to Heroku, and it does not work. Why? Because you changed databases from SQLite3 to PostgreSQL.</p><p>While writing my latest Ruby on Rails application, I ran into this problem when trying to migrate my database on Heroku:</p><pre>StandardError: An error has occurred, this and all later migrations canceled:                                               </pre><pre>PG::UndefinedTable: ERROR:  relation &quot;departure_airports&quot; does not exist     <br>                  <br>: CREATE TABLE &quot;flights&quot; (&quot;id&quot; bigserial primary key, &quot;departure_airport_id&quot; bigint, &quot;arrival_airport_id&quot; bigint, &quot;take_off&quot; timestamp, &quot;duration&quot; time, &quot;created_at&quot; timestamp NOT NULL, &quot;updated_at&quot; timestamp NOT NULL, CONSTRAINT &quot;fk_rails_b88a099d1c&quot; <br>                      <br>FOREIGN KEY (&quot;departure_airport_id&quot;)                         <br>  REFERENCES &quot;departure_airports&quot; (&quot;id&quot;), <br>  CONSTRAINT &quot;fk_rails_91bb366993&quot;                       <br>FOREIGN KEY (&quot;arrival_airport_id&quot;)                         <br>  REFERENCES &quot;arrival_airports&quot; (&quot;id&quot;))</pre><p>But… but.. everything was working locally using SQlite3. What’s the problem?</p><p>The problem lies within the migration file used for creating the relationships between the flight and airport models. This is what I had:</p><pre>class CreateFlights &lt; ActiveRecord::Migration[5.1] <br>  def change<br>    create_table :flights do |t|<br>      t.references :departure_airport,  foreign_key: true<br>      t.references :arrival_airport,    foreign_key: true<br>      t.datetime :take_off<br>      t.time :duration<br>      t.timestamps                           <br>    end<br>  end<br>end</pre><p>What’s the problem? The lines t.references</p><p>Great, we’ve found the problem. Now how do I fix it?</p><p>The good news is that this is easily fixed. Instead of using .references we will instead create the foreign keys and indexes ourselves.</p><p>To do this, we will change t.references to t.integer and change the column name from :departure_airport to :departure_airport_id</p><p>It is then necessary to add the foreign key and index to create the relationship within the database. We do this by adding</p><pre>add_foreign_key :flights, :airports, column: :departure_airport_id<br>add_index :flights, :departure_airport_id</pre><p>Repeat the same process for :arrival_airportto give us a final migration file of</p><pre>class CreateFlights &lt; ActiveRecord::Migration[5.1]<br>  def change<br>    create_table :flights do |t|<br>      t.integer :departure_airport_id<br>      t.integer :arrival_airport_id<br>      t.datetime :take_off<br>      t.time :duration</pre><pre>      t.timestamps<br>    end</pre><pre>    add_foreign_key :flights, <br>                    :airports, <br>                    column: :departure_airport_id<br>    add_index :flights, :departure_airport_id</pre><pre>    add_foreign_key :flights, <br>                    :airports, <br>                    column: :arrival_airport_id<br>    add_index :flights, :arrival_airport_id<br>  end<br>end</pre><p>Push your new code to Heroku and your migrations should now work</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab582a62c7b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing Debian VM]]></title>
            <link>https://mindovermiles262.medium.com/installing-debian-vm-7a78e04759a2?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a78e04759a2</guid>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[odin]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Sun, 12 Feb 2017 22:50:19 GMT</pubDate>
            <atom:updated>2017-03-07T16:10:05.588Z</atom:updated>
            <content:encoded><![CDATA[<p>Getting off the ground can be difficult. All the new vocabulary, procedures, and the excitement of getting started in web development can be overwhelming. I’ve set up this tutorial to guide you through the installation process of Debian in a Virtual Machine (VM).</p><p>Debian is a great choice for VM since it is lightweight and quick. Oftentimes VM Environments are sluggish since your local computer is actually processing data from two different desktops. By installing the <a href="https://en.wikipedia.org/wiki/LXDE">LXDE</a> version of Debian, performance can be salvaged.</p><p>Installation may seem complicated, but by following this guide you should have no problems. Should an error occur, help is available on <a href="https://gitter.im/TheOdinProject/theodinproject">The Odin Project’s chat room</a></p><p>Let’s Get Started!</p><h3>Downloading the Debian LXDE Image</h3><p>First, we need to download the Debian LXDE image. Open a new window in your internet browser and go to <a href="http://www.debian.org/CD/">http://www.debian.org/CD/</a> where we’ll want to click the 4th option, “Download CD/DVD Images using HTTP or FTP” (Alternatively, if you know how to use BitTorrent please follow that link)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*ZAeYDY4kRA8Pasr1." /></figure><p>Next, we’ll want to select the “stable” release of Debian</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*SfVzHeoXxFUgEBIF." /></figure><p>and download the CD version corresponding to the architecture of your computer’s processor. If your computer is less than 5 years old, you’ll most likely want to download the 64-bit “amd64” option. If you know your computer is 32-bit, download the “i386” CD image. If you have any questions regarding this, The Odin Project’s chat room is the place for <a href="https://gitter.im/TheOdinProject/theodinproject">help</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*j4t9PO3RWaw5u2ip." /></figure><p>Lastly, we’ll want to download the LXDE version</p><p>Your download should start.</p><h3>Installing Virtual Box</h3><p>The next step is to install Oracle’s Virtual Box. This is a program which emulates a new computer. Within the program you can install new operating systems and run them from “inside” of the operating system already on your computer. This allows a user to install and run Linux from inside of a Window’s machine. Pretty neat, huh?</p><p>To install, navigate your internet browser to <a href="https://www.virtualbox.org/wiki/Downloads">https://www.virtualbox.org/wiki/Downloads</a> and click on “Windows Hosts” if your computer is running Windows, or “OS X Hosts” if your computer is a Mac.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*EFECapSkFUuByQYD." /></figure><p>When the download is complete, install like any other program on your computer.</p><h3>Installing Debian in Virtual Box</h3><p>Now the fun really begins! When Virtual Box is installed and your Debian CD image is downloaded, you’re ready to begin. Open Virtual Box and select “New” to create a new Virtual Machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*89J6nJk67bIcz6Ne." /></figure><p>Next, we’ll want to name our new VM Debian. Type: Linux and Version: Debian should automatically populate (change). Slide the memory size to 2048 MB and ensure “Create a virtual hard disk now” is selected. Click Create</p><p>The next window that pops up is going to help you create a new “Hard Drive” for your Virtual machine. I recommend at least 20.00 GB of space to be safe. Leave everything else default and click Create</p><p>Great! Now you have your VM Hard Drive set up and now it’s time to install Debian. On the main Virtual Box menu, click Start A new window will pop up and prompt you for an installation image. Click the folder icon and find your Debian.iso you downloaded earlier (usually in your downloads folder), then click Start</p><p>Next, select “graphical install” from the boot menu by using the up and down arrows on your computer and hit enter</p><p><strong>**NOTE:</strong> If your mouse disappears and you need it back, hit the command button on the left side if using a Mac, or hit the CTRL key on the right side of the keyboard if using Windows.</p><p>Follow the on screen instructions to select your Language, Location, and Keyboard. The installer will do it’s thing for a few moments then prompt you for a hostname. You can leave it as debian. Click Continue. Next, if you have a domain name, enter it. If you don’t have one enter odin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*l1Vw5psoeB7Vd7DK." /></figure><p>Since we are running Debian in a virtual machine, these network settings don’t matter as much as if we were installing them directly to the host computer. Click continue after you’ve entered your domain name</p><p>The next step prompts you to enter a “root” password. This is your MASTER password. Enter it, then retype it and click continue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*YVZwFFfSN5iCzr_U." /></figure><p>Then enter an your full name. It’s possible that this name will be shared later so if you’re sensitive to personal security please use a nickname</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*GmHbE3P41c_el2Sr." /></figure><p>Next, enter your new username. Again, it’s possible that this name will be shared later so if you’re sensitive to personal security please use a nickname</p><p>//d_user_name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*DBsJIvD_RExqsvZV." /></figure><p>Enter a password for your USER account</p><p>//d_user_password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*nkwxCLF1SPXMHyNw." /></figure><p>Configure your clock by selecting your Time Zone. Click “Continue” and the installer will run for a few moments. Congratulations! You’re well on your way to becoming a web developer! Take a step back and take a breath. See how easy this can be?</p><p>The next part of the Debian Installation is to partition the virtual hard drive. This may look and feel complicated and risky, but in reality it is very low risk since we’re running a VM. No harm can be done to your actual hard drive.</p><p>When prompted, go ahead and select “Guided — use entire disk”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*CoDBsWB67yybR2Gr." /></figure><p>Then select the only partition available. Click “continue”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*5agNJDTITU75u4bn." /></figure><p>Go ahead and select “All files in one partition (recommended for new users)” This will put all your files into one “hard drive” as opposed to separate “hard drives” for system files and your user files. Click “Continue”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*cj4eXbmmH7ni4PYr." /></figure><p>The installer will then run some processes and present you with a confirmation screen. Click “continue”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*UQ_1GDNSFxFfBICB." /></figure><p>then “yes” to write changes to the disk</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*09main6gIuvZW_LL." /></figure><p>We’re almost done installing Debian! After you write the changes to the disk the installer will take over for a while and copy, then install all the necessary Linux files. This will take a some time</p><p>After a few minutes you’ll be prompted to use a network mirror. Check “yes” and then click “continue”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*pycmtzLatvIOQpnZ." /></figure><p>Then choose your country, and mirror. Choose any mirror you wish, it doesn’t really matter. Click “continue.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*ZiOpp9Wa7HIZltaZ." /></figure><p>If you use a proxy server enter the information in the next screen. If not, leave the field blank. The installer will do it’s thing again for a few minutes. While you wait, go grab a cup of coffee. You deserve it!</p><p>When you return you’ll be prompted if you want to contribute to an anonymous package survey. Choose what you wish to participate then click “continue” The installer will resume for a minute or two.</p><p>When prompted, confirm your software selection. These features can be added at a later time, so for now just click “continue”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*V_I7zxVUIjBsMv_z." /></figure><p>AAAAND now we wait (~30min). Don’t worry, the hard part is done. Hang tight and I’ll see you when the installation is finished!</p><p>When you come back, click “yes” to install GRUB and click “continue”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*rah0nx5UQLarg1XT." /></figure><p>then select the /dev/sda/ option and click “continue”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*_7_kfJNKjLPP3ipt." /></figure><p>You did it! You’ve successfully installed Debian in a Virtual Machine! Click “continue” to restart your VM</p><p>When prompted, enter your login username and password</p><p>That’s it! Now you’re ready to run <a href="http://installfest.railsbridge.org/installfest/linux">Installfest</a>. Debian’s terminal is named LXTerminal. Now — off you go! Remember to take your time with Installfest and everything should be okay!</p><p><em>Originally published at </em><a href="https://mindovermiles262.wordpress.com/2017/02/12/installing-debian-vm/"><em>mindovermiles262.wordpress.com</em></a><em> on February 12, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a78e04759a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Finding” Time]]></title>
            <link>https://mindovermiles262.medium.com/finding-time-b526c18df094?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b526c18df094</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[odin]]></category>
            <category><![CDATA[time-management]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Wed, 08 Feb 2017 04:21:59 GMT</pubDate>
            <atom:updated>2017-03-07T16:07:49.085Z</atom:updated>
            <content:encoded><![CDATA[<p>I get it. We’re all busy people. Working, commuting, eating, sleeping, relaxing, seeing friends and family, or having fun; they all take time. Where does learning to code fit into all of this?</p><p>It doesn’t.</p><p>Wait… what?</p><p>You can’t <strong>find </strong>time to learn something new. You <strong>make</strong> time. Without specifically scheduling time each day to learn, the odds of you sitting down and learning to code are as good as finding $50 on the ground.</p><p>Specifically, you can do these three things to increase your odds.</p><p>The first step is to plan your life. Do you work from 9–5 everyday? Great! That’s the first step to planning your life. Add it to your calendar. Oh.. you don’t have a calendar? Let me remind you that Google Calendar is simple to use and syncs across pretty much every platform there is. It’s also capable of scheduling repeated events. If you’re more of the pen-0n-paper kind of organizer, I recommend <a href="http://www.passionplanner.com/">Passion Planner</a>. I’ve been using one for several years now and it’s become my lifeline for all things important. Nice binding, quality pages, great goal planning.</p><p>Now — what else do you have going on? Bar League Hockey every Tuesday from 7–10? Add it to the calendar. The sooner you can set a schedule for your life, the better your learning will be.</p><p>As you fill in your calendar you will start to notice openings. These are the times you need to reserve for learning. Aim for at least 30 minutes each day, an hour per day on weekends.</p><p>Secondly, find a place that’s conducive to learning. Everyone is different. Maybe you learn best at a coffee shop with soft music playing. Maybe you need silence. Whatever you need, find it. Get away from distractions.</p><p>Lastly, be engaged throughout the day. Learning doesn’t have to happen only during the half hour per day you schedule. When you are stuck in traffic try to remember what you learned during the previous lesson. What new commands did you learn? What’s the syntax? (Did you forget the semicolon?) Maybe you can picture a website you visited that day in your mind and imagine how you would recreate the structure using HTML and CSS. Or when faced with a problem at work think about how a programmer would solve the issue. For example — at your job you have to repeat a procedure multiple times. How would you write a ruby script to tell you how many of each item you need if you process <em>x</em> samples per day? Being actively engaged throughout the day is the best way to learn without being at a computer. It may also give you inspirations for future projects.</p><p>Remember — a little time each day leads to a lifetime of success</p><p><em>Originally published at </em><a href="https://mindovermiles262.wordpress.com/2017/02/07/finding-time/"><em>mindovermiles262.wordpress.com</em></a><em> on February 8, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b526c18df094" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[init (git it?)]]></title>
            <link>https://mindovermiles262.medium.com/init-git-it-7f9ed031885b?source=rss-a5cc050838e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f9ed031885b</guid>
            <category><![CDATA[odin]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Andy]]></dc:creator>
            <pubDate>Fri, 03 Feb 2017 02:52:28 GMT</pubDate>
            <atom:updated>2017-03-07T16:11:21.934Z</atom:updated>
            <content:encoded><![CDATA[<p>Today is the start of something new. Let me explain –</p><p>At the start of each year I set one resolution that will take a year to complete. Last year, for example, I resolved to run 2016km (1252 miles). That’s 3.4 miles. Everyday. I met my goal.</p><p>This year is going to take things in an entirely different direction. I resolve to become a web developer by the end of 2017.</p><p>It’s going to be very challenging, and I’m only beginning to understand some of the challenges in achieving this goal. The past month I’ve spent pouring over “Web Development 101” from The <a href="http://www.theodinproject.com/">Odin Project</a>, an open-source web developer curriculum compiling all the best lessons from around the web. This first part, Web Development 101, contains mini-segments for all of the languages in the project. I’ve already learned a fair amount from each HTML, CSS, JavaScript, Ruby, and Ruby on Rails Framework. I also have done some independent studies in Python.</p><p>To achieve this ambitious goal I devote at least 30 minutes per day to working on the project. Most days I get so focused on finishing a segment that I spend 2+ hours after work learning. With the skills I’ve developed over the past month I am feeling confident in my skill set — which brings me to the beginning. Today is the start of something new.</p><p>I bought my own <a href="http://www.andyduss.com/">website</a> today. It’s not much right now, but it’s mine.</p><p>I intend to turn it into a portfolio of my work showing off all I can bring to the table. Along the way I’ll be updating this blog for self-reflection as well as a log to record progress. Perhaps you too are getting started with coding. I hope this blog serves you well and inspires you to continue what you’re doing.</p><p><em>Originally published at </em><a href="https://mindovermiles262.wordpress.com/2017/02/03/first-blog-post/"><em>mindovermiles262.wordpress.com</em></a><em> on February 3, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f9ed031885b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>