<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Rails on WormBytes</title><link>https://www.wormbytes.ca/tags/rails/</link><description>Recent content in Rails on WormBytes</description><generator>Hugo -- gohugo.io</generator><language>en-ca</language><managingEditor>Robert James Kaes</managingEditor><copyright>Robert James Kaes. All Rights Reserved.</copyright><lastBuildDate>Mon, 30 Apr 2018 15:58:06 -0400</lastBuildDate><atom:link href="https://www.wormbytes.ca/tags/rails/index.xml" rel="self" type="application/rss+xml"/><item><title>Gem Home for Fish Shell</title><link>https://www.wormbytes.ca/2018/04/30/gem-home-for-fish-shell/</link><pubDate>Mon, 30 Apr 2018 15:58:06 -0400</pubDate><author>Robert James Kaes</author><guid>https://www.wormbytes.ca/2018/04/30/gem-home-for-fish-shell/</guid><description>&lt;p&gt;In a recent &lt;a href="https://www.twitch.tv/garybernhardt"&gt;twitch stream&lt;/a&gt;,
&lt;a href="https://twitter.com/garybernhardt"&gt;Gary Bernhardt&lt;/a&gt; showed a bit of
behind-the-scenes in how he prepares his development environment for recording
a screencast.&lt;/p&gt;
&lt;p&gt;One of the tools he showed in passing was
&lt;a href="https://github.com/postmodern/gem_home"&gt;&lt;code&gt;gem_home&lt;/code&gt;&lt;/a&gt; by
&lt;a href="https://postmodern.github.io/"&gt;Hal Brodigan&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;gem_home&lt;/code&gt; is a simple script that manipulates
&lt;a href="https://www.ruby-lang.org/"&gt;Ruby&amp;rsquo;s&lt;/a&gt; &lt;code&gt;GEM_HOME&lt;/code&gt; and &lt;code&gt;GEM_PATH&lt;/code&gt; environmental
variables in order to keep separate ruby gem locations.&lt;/p&gt;
&lt;p&gt;By using &lt;code&gt;gem_home&lt;/code&gt;, there is no longer a requirement to prefix all ruby
commands with &lt;code&gt;bundle exec&lt;/code&gt;. All the gems for a project are local to the
project, which eliminates conflicts that might arise when gems for multiple
projects are mixed together in one location.&lt;/p&gt;
&lt;p&gt;Eliminating the need for &lt;code&gt;bundle exec&lt;/code&gt; allows commands such as &lt;code&gt;rspec&lt;/code&gt; to
execute &lt;em&gt;much&lt;/em&gt; quicker!&lt;/p&gt;
&lt;p&gt;Unfortunately for me, I recently switched over to using
&lt;a href="https://fishshell.com/"&gt;fish shell&lt;/a&gt; from &lt;a href="https://www.zsh.org/"&gt;ZSH&lt;/a&gt;. Hal&amp;rsquo;s &lt;code&gt;gem_home&lt;/code&gt; only supports
&lt;a href="https://www.gnu.org/software/bash/"&gt;Bash&lt;/a&gt; and &lt;a href="https://www.zsh.org/"&gt;ZSH&lt;/a&gt;. 🙁&lt;/p&gt;
&lt;p&gt;One nice thing about &lt;code&gt;gem_home&lt;/code&gt; is how simple and straightforward it is. In a
few hours I was able to replicate its functionality as a &lt;a href="https://fishshell.com/"&gt;fish shell&lt;/a&gt; compatible
script!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/rjkaes/gem_home"&gt;https://github.com/rjkaes/gem_home&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you&amp;rsquo;re using ruby and &lt;a href="https://fishshell.com/"&gt;fish shell&lt;/a&gt;, I would highly recommend using my
implementation of &lt;code&gt;gem_home&lt;/code&gt; along with
&lt;a href="https://github.com/JeanMertz/"&gt;Jean Mertz&amp;rsquo;s&lt;/a&gt;
wrapper around &lt;a href="https://github.com/JeanMertz/chruby-fish"&gt;chruby&lt;/a&gt;. Both of
these play well together.&lt;/p&gt;</description></item><item><title>Enabling Vim Rails</title><link>https://www.wormbytes.ca/2018/01/17/enabling-vim-rails/</link><pubDate>Wed, 17 Jan 2018 11:17:42 -0500</pubDate><author>Robert James Kaes</author><guid>https://www.wormbytes.ca/2018/01/17/enabling-vim-rails/</guid><description>&lt;p&gt;&lt;a href="https://github.com/tpope/vim-rails"&gt;vim-rails&lt;/a&gt; is enabled only if
&lt;code&gt;config/environment.rb&lt;/code&gt; is present in the
&lt;a href="https://www.rubyonrails.org/"&gt;Rails&lt;/a&gt; working directory.&lt;/p&gt;
&lt;p&gt;At work, we have an engine based working directory that does not contain this
file (as there&amp;rsquo;s an embedded application within the engine.)&lt;/p&gt;
&lt;p&gt;To enable vim-rails, I need to do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a2f"&gt;echo&lt;/span&gt; &lt;span style="color:#b44"&gt;&amp;#34;load ::File.expand_path(&amp;#39;../../embedded-app/config/environment.rb&amp;#39;,__FILE__)&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; config/environment.rb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir -p .git/info
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a2f"&gt;echo&lt;/span&gt; &lt;span style="color:#b44"&gt;&amp;#34;config/environment.rb&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; .git/info/exclude
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Within the repo to enable vim-rails support.&lt;/p&gt;</description></item><item><title>Checking for Cookie Deletion by a Rails Controller with RSpec</title><link>https://www.wormbytes.ca/2014/04/15/checking-for-cookie-deletion-by-a-rails-controller-with-rspec/</link><pubDate>Tue, 15 Apr 2014 12:00:00 +0000</pubDate><author>Robert James Kaes</author><guid>https://www.wormbytes.ca/2014/04/15/checking-for-cookie-deletion-by-a-rails-controller-with-rspec/</guid><description>&lt;p&gt;Today I needed to prove that my Rails controller method deleted a cookie. After Googling for the answer (without success), I came up with the following.&lt;/p&gt;
&lt;p&gt;Within your controller:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;cookies.delete(&amp;#39;cookie-to-delete&amp;#39;)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In your controller spec you can check that the cookie was deleted with:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;expect(response.cookies).to include(&amp;#39;cookie-to-delete&amp;#39; =&amp;gt; nil)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Rails sets the cookies to be deleted to a value of nil. By checking for the presence of both the cookie name with a value of nil, you can ensure your controller code deleted the cookie.&lt;/p&gt;</description></item></channel></rss>