<?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 Andrew Tomaka on Medium]]></title>
        <description><![CDATA[Stories by Andrew Tomaka on Medium]]></description>
        <link>https://medium.com/@atomaka?source=rss-571787308f4b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*txeHvGkmRUGvf0gV.jpeg</url>
            <title>Stories by Andrew Tomaka on Medium</title>
            <link>https://medium.com/@atomaka?source=rss-571787308f4b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 04:28:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@atomaka/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[Write Good Git Commits]]></title>
            <link>https://medium.com/@atomaka/write-good-git-commits-b54847d3b271?source=rss-571787308f4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b54847d3b271</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Andrew Tomaka]]></dc:creator>
            <pubDate>Tue, 18 Apr 2017 00:34:29 GMT</pubDate>
            <atom:updated>2017-04-18T00:34:29.149Z</atom:updated>
            <content:encoded><![CDATA[<p>Writing quality Git commits has been written about to death, but it is so important that I could not help myself from sharing my thoughts on the subject. Mostly, I will be rehashing what <a href="http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html">Tim Pope has shared</a>, but I will also include a few of the things that I have used to improve my source histories.</p><h3>Limit the subject of your commit to 50 characters</h3><p>Many people live life as I do: at the command line. Limiting to 50 characters allows room for us to use an 80 character width for commands such as git rebase --interactive without width concerns. Even for those in a more modern IDE, the limit is important.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*wbdBQ1P-Lcka7i9B0yCm5A.png" /></figure><p>As commit messages get longer, it becomes more difficult for everyone to traverse your history.</p><h3>Use the commit body for important details</h3><p>It is very rare that I see people extend their commit histories into the body portion of a commit but it is the perfect place to offer extra details. Things like what resources you used to make a specific decision are better left in the commit history than in code comments most of the time. In a <a href="https://github.com/atomaka/dotfiles/commit/28a3897995ff21f63f7893f43582532e4717b8d9">recent commit to my dotfiles</a>, I added a quick alias to correct a TouchBar issue I was having.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80093e32d6882def28baf484b0e45cfa/href">https://medium.com/media/80093e32d6882def28baf484b0e45cfa/href</a></iframe><p>Without these details, I might never be able to find the source for why I added this.</p><p>Also, limit the line length in the body to 72 characters.</p><h3>Do not use the --message option</h3><p>Pretty much everyone I watch make a commit will do so directly at their command prompt with git commit -m. Forcing yourself into an editor will encourage you to add additional details about a commit message. Additionally, your editor can be configured to alert you to the 50/72 rule. Simply add au FileType gitcommit set tw=72 to your vimrc to auto wrap git messages at 72 characters if vim is configured as your Git editor. <a href="https://github.com/tpope/vim-git">vim-git</a> is also a fantastic option that will highlight based on these rules.</p><p>If you are struggling with breaking your -m habit, try creating a bash function to prevent its usage.</p><pre>function git {<br>  if [[ $@ == &quot;commit -m&quot; ]]; then<br>    echo &quot;Do not specify -m for commit&quot;<br>  else<br>    command git &quot;$@&quot;<br>  fi<br>}</pre><h3>Commit as if giving a command</h3><p><a href="https://chris.beams.io/posts/git-commit/">How to Write a Git Commit Message</a> made me consider the subject of my commits a little more. In bullet point 5, Chris says “Use the imperative mood in the subject line.” Considering Git itself follows this rule, it made perfect sense to jump on board.</p><pre>Merge branch &#39;bugfix/correct-spacing</pre><p>And</p><pre>Revert &quot;Implement person CRUD&quot;</pre><p>The best advice I picked up was write your commit as if you are completing the following sentence: “If applied, this commit will…”</p><h3>Rebase your branches, but leave master alone</h3><p>Rebasing is a heated topic in the community but the one thing that everyone can agree on is leaving master alone. Once your commit has made it there, it is history and should never be changed. However, your branch is your story. You get to tell it however you want so craft it in a way that is useful to the reader.</p><p>For me, this is particularly important because the second thing I do when reviewing a new code base is look at the commit history to see to story of the application. Unfortunately, most are riddled with messages like “fixed typo” or “asdf” and the history becomes unreadable.</p><p>Take care in crafting your git messages and you will find much more value in your git logs!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b54847d3b271" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A More Flexible Dockerfile for Rails]]></title>
            <link>https://medium.com/@atomaka/a-more-flexible-dockerfile-for-rails-166227af69fc?source=rss-571787308f4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/166227af69fc</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Andrew Tomaka]]></dc:creator>
            <pubDate>Wed, 01 Mar 2017 14:19:30 GMT</pubDate>
            <atom:updated>2017-03-01T14:19:30.425Z</atom:updated>
            <content:encoded><![CDATA[<p>One of my primary motivations for working with <a href="https://www.docker.com/">Docker</a> was creating a single artifact that I could toss into any environment. It has been fantastic at this. I can throw together a simple Dockerfile that will build my <a href="http://rubyonrails.org/">Rails</a> application as an image for production in about five minutes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4bb6aca64108e9a1c9dc07c39f19a15/href">https://medium.com/media/d4bb6aca64108e9a1c9dc07c39f19a15/href</a></iframe><p>Except now that when I need to run the application’s test suite, I do not have the dependencies I need. That Dockerfile might look something like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfec2991ef76ca9a943e201d825dbba1/href">https://medium.com/media/dfec2991ef76ca9a943e201d825dbba1/href</a></iframe><p>Many people decide to include both of these Dockerfiles in their repository as Dockerfile and Dockerfile.dev. This works perfectly fine. But now we have a production Dockerfile that never gets used during development. Of course, it is going through at least one staging environment (hopefully) but it would be nice if we had a little more testing against it.</p><p>Much like Docker provides us the ability to have a single artifact to move from system to system, I wanted to have a single Dockerfile shared between all environments. Luckily, Docker provides us with <a href="https://docs.docker.com/engine/reference/builder/#/arg">build arguments</a>. A build argument allows us to specify a variable when building the image and then use that variable inside our Dockerfile.</p><p>In our current Rails Dockerfile, we have two primary differences between our environments:</p><ol><li>The gem groups that are installed</li><li>The environment that the application runs as</li></ol><p>Bundler’s <a href="http://bundler.io/man/bundle-config.1.html#LIST-OF-AVAILABLE-KEYS">BUNDLE_WITHOUT</a> allows us to specify the gem groups to skip via an environment variable making both of these resolvable through environment configuration. Using this, our shared Dockerfile could look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12f5b27d1164266261097379d03bda3f/href">https://medium.com/media/12f5b27d1164266261097379d03bda3f/href</a></iframe><p>The secret sauce here is ARG BUNDLE_WITHOUT=test:development. Running docker build -t rails-app . will use the default value provided for the BUNDLE_WITHOUT build argument, test:development, and a production Docker image will be built. And if we specify the appropriate build arguments, we can generate an image suitable for development.</p><pre>docker build -t rails-app --build-arg BUNDLE_WITHOUT= --build-arg RAILS_ENV=development .</pre><p>will generate our Docker image with all test and development dependencies available. Typing this for building in development would get pretty tedious so we can use docker-compose to make it easier</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85301cb5b3da9ab90e43b768f4a7b20b/href">https://medium.com/media/85301cb5b3da9ab90e43b768f4a7b20b/href</a></iframe><p>Now, docker-compose up -d is all we need in development to both build and launch our development image.</p><p>Finally, we have a single Dockerfile that can be used to build an image for any of our application’s needs. Of course, there are some trade-offs. For example, build time in development will suffer in some cases. But I have found only maintaining a single Dockerfile to be worth these costs.</p><p>Have another way to deal with this issue? Please share!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=166227af69fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Singular and Plural Rails Routes for the Same Resource]]></title>
            <link>https://medium.com/@atomaka/single-and-plural-rails-routes-for-the-same-resource-330d985b6595?source=rss-571787308f4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/330d985b6595</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[restful]]></category>
            <dc:creator><![CDATA[Andrew Tomaka]]></dc:creator>
            <pubDate>Fri, 18 Nov 2016 02:43:02 GMT</pubDate>
            <atom:updated>2016-11-21T15:17:53.025Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes when building your API with Rails, <a href="http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api">following best practices</a> may seem difficult. I recently came across one of these cases and was tempted to take a shortcut. However, I held strong and eventually came to a quality RESTful solution — but not without issue.</p><p>I wanted to allow users of my API to quickly access their own user profile. Our application had already implemented a route to allow this via GET /profiles/:id and simply implemented with resources :profiles, only: [:show] in our routes configuration.</p><p>Unfortunately, our API users wanted to be able to access their profile without providing their ID. My first pass at resolving this was passed in a “fake resource” to accomplish this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77dcb7a4a93e8bb04ed1d43ddf4d914a/href">https://medium.com/media/77dcb7a4a93e8bb04ed1d43ddf4d914a/href</a></iframe><p>But I had broken one of the RESTful best practices. /profiles/me is not an actual resource but we are pretending it is. So I looked to the <a href="http://guides.rubyonrails.org/routing.html">Rails routes documentation</a> for guidance and came across <a href="http://guides.rubyonrails.org/routing.html#singular-resources">singular resources</a>.</p><pre>Sometimes, you have a resource that clients always look up without referencing an ID. For example, you would like /profile to always show the profile of the currently logged in user.</pre><p>I should not have been surprised that my exact use case was cited!</p><p>Now we are back on track! I get to go back to my simple route declaration with resource :profile, only: :show and without changing my controller code at all.</p><p>But now I needed users to be able to access each other’s profiles. Again, the Rails documentation had me covered.</p><pre>Because you might want to use the same controller for a singular route (/account) and a plural route (/accounts/45), singular resources map to plural controllers. So that, for example, resource :photo and resources :photos creates both singular and plural routes that map to the same controller (PhotosController).</pre><p>And our implementation stays clean.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90ebd7959f2f17c94be8a8f67a82dcf1/href">https://medium.com/media/90ebd7959f2f17c94be8a8f67a82dcf1/href</a></iframe><p>This was awesome until I needed to use path helpers. With this implementation, profile_path(:id) works as expected but profile_path does not. If the order is reversed in the routes configuration, profile_path will work and profile_path(:id) will not. This is the result of a bug in the Rails core that touches some pretty intricate code that is linked to other issues. <a href="https://github.com/rails/rails/issues/1769">One has even been open for five years</a>!</p><p>And we can work around that one as well by <a href="http://guides.rubyonrails.org/routing.html#overriding-the-named-helpers">overriding the named helpers</a>. Passing as: to our resource definition creates the helpers with a new name.</p><p>Our final code is ready!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f751f867b03c9a91d1d1ecfb27579778/href">https://medium.com/media/f751f867b03c9a91d1d1ecfb27579778/href</a></iframe><p>In our application, we can reference a generic profile with profile_path(:id) while still having current_profile_path to direct the user to their own profile.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=330d985b6595" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Your Docker Images with GitLab CI]]></title>
            <link>https://medium.com/@atomaka/testing-your-docker-images-with-gitlab-ci-d25a03b16461?source=rss-571787308f4b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d25a03b16461</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Andrew Tomaka]]></dc:creator>
            <pubDate>Sat, 05 Nov 2016 06:34:43 GMT</pubDate>
            <atom:updated>2016-11-05T06:34:43.068Z</atom:updated>
            <content:encoded><![CDATA[<p>I have been using <a href="https://about.gitlab.com/">GitLab</a> for over four years. My <a href="https://github.com/gitlabhq/gitlabhq/commit/0760ba3efb7566b9f56bb066f4b15ba8ea34e1e7">first commit</a> to the project came nearly three years ago. And although I was pretty disappointed when they began <a href="https://about.gitlab.com/2013/07/22/announcing-gitlab-enterprise-edition/">releasing an enterprise edition</a>, the community edition of the project remains impressive. More recently, GitLab has included a <a href="https://about.gitlab.com/gitlab-ci/">continuous integration software</a> along with their code collaboration solution.</p><p>Recently, I have been using this to produce <a href="https://www.docker.com/">Docker</a> images for my production environment. Although I had been using Docker for all of my build stages, I was never using the image I was producing for validation. Since I want to be as sure as I can that my production images are functioning, I decided to update my build to use the project Dockerfile to run tests.</p><p>I looked around and found a <a href="http://sirile.github.io/2016/09/29/minimal-go-containers-with-docker-and-gitlab-ci.html">few</a> <a href="https://www.andrewmunsell.com/blog/ci-cd-with-docker-containers/">articles</a> on using Docker with Gitlab CI. Unfortunately, they all outlined methods that <a href="https://www.stefanwienert.de/blog/2015/11/07/gitlab-ci-with-docker-starting-guide/">did not test the image</a> directly or did so in a <a href="http://blog.lwolf.org/post/How-to-build-and-test-docker-images-in-gitlab-ci/">complicated way</a>. I thought I could do better.</p><p>We always want to use Docker for our builds, but running Docker inside of Docker is not recommended. To resolve this, we can mount the host system’s Docker socket inside the container when creating our test runner for building images.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c73cbb1949ad77c0fad21914bed61647/href">https://medium.com/media/c73cbb1949ad77c0fad21914bed61647/href</a></iframe><p>Now that we are using the host Docker, we can leverage its image storage and caching for our build. We can also use that image in our other build tasks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d29d5faa72dc76cb1644434e057cb836/href">https://medium.com/media/d29d5faa72dc76cb1644434e057cb836/href</a></iframe><p>The container built from our project Dockerfile is now being directly tested by our continuous integration. As you can see, we can also use any container links without writing extra code.</p><p>Clean and simple!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d25a03b16461" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>