<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shaun Ambrose &#187; Ruby on Rails</title>
	<atom:link href="http://www.shaunambrose.com/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shaunambrose.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 01 Apr 2012 04:21:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Automatic VCR cassette naming for RSpec and Cucumber</title>
		<link>http://www.shaunambrose.com/2012/03/19/automatic-vcr-cassette-naming-for-rspec-and-cucumber/</link>
		<comments>http://www.shaunambrose.com/2012/03/19/automatic-vcr-cassette-naming-for-rspec-and-cucumber/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 19:44:10 +0000</pubDate>
		<dc:creator>Shaun</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[vcr]]></category>

		<guid isPermaLink="false">http://www.shaunambrose.com/?p=746</guid>
		<description><![CDATA[Here&#8217;s how to configure VCR to automatically name cassettes for RSpec and Cucumber tests. After getting this is setup, using VCR to speed up your tests (with HTTP requests) is so easy, it&#8217;s a big win for very little work. RSpec After you get the VCR gem installed, use the configure_rspec_metadata! option to get VCR [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to configure VCR to automatically name cassettes for RSpec and Cucumber tests. After getting this is setup, using VCR to speed up your tests (with HTTP requests) is so easy, it&#8217;s a big win for very little work.<br />
<span id="more-746"></span></p>
<p><strong>RSpec</strong><br />
After you get the VCR gem installed, use the configure_rspec_metadata! option to get VCR to automatically name your cassettes based off your test&#8217;s spec description.</p>
<p>Here&#8217;s a sample VCR confguration (spec/support/vcr.rb):</p>
<pre>
<code>
VCR.configure do |c|
  c.cassette_library_dir = 'spec/cassettes'
  c.hook_into :fakeweb
  c.configure_rspec_metadata!
end

RSpec.configure do |c|
  c.treat_symbols_as_metadata_keys_with_true_values = true
end
</code>
</pre>
<p>There are more details about the configure_rspec_metadata! option here: <a href="https://www.relishapp.com/myronmarston/vcr/v/2-0-0/docs/test-frameworks/usage-with-rspec-metadata">https://www.relishapp.com/myronmarston/vcr/v/2-0-0/docs/test-frameworks/usage-with-rspec-metadata</a></p>
<p>After this is setup, you just need to tag your specs, with :vcr. Here&#8217;s a sample:</p>
<pre>
<code>
it "should make me a sandwich", :vcr do
&hellip;
end
</code>
</pre>
<p><strong>Cucumber</strong><br />
For Cucumber, you need to use the use_scenario_name option. (This option isn&#8217;t in a release version of VCR yet, so you&#8217;ll have to use the master branch version on GitHub.)</p>
<p>Here&#8217;s a sample VCR confguration for Cucumber (features/support/vcr.rb):</p>
<pre>
<code>
VCR.configure do |c|
  c.cassette_library_dir = 'features/cassettes'
  c.hook_into :fakeweb
end

VCR.cucumber_tags do |t|
  t.tag '@vcr', use_scenario_name: true
end
</code>
</pre>
<p>Then after this is setup, you can tag your scenarios or features with @vcr and it will automatically name the cassette using the scenario name combined with the feature name.</p>
<pre>
<code>
@vcr
Feature: Truffle shuffle
&hellip;
</code>
</pre>
<p>It&#8217;s really simple to setup VCR for automatic cassette naming for both RSpec and Cucumber. Which makes it really effortless to use VCR with the :vcr and @vcr tags. Which makes using VCR a no brainer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunambrose.com/2012/03/19/automatic-vcr-cassette-naming-for-rspec-and-cucumber/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install gems without documentation by default</title>
		<link>http://www.shaunambrose.com/2011/10/24/how-to-install-gems-without-documentation-by-default/</link>
		<comments>http://www.shaunambrose.com/2011/10/24/how-to-install-gems-without-documentation-by-default/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 18:18:11 +0000</pubDate>
		<dc:creator>Shaun</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[how to]]></category>

		<guid isPermaLink="false">http://www.shaunambrose.com/?p=609</guid>
		<description><![CDATA[Here&#8217;s a quick tip I learned this weekend on how to get all your RubyGems installed without documentation by default. I knew there was a way to prevent documentation from being installed at the command line with the &#8211;no-rdoc &#8211;no-ri options: $ gem install rails --no-rdoc --no-ri But there&#8217;s another way to prevent documentation from [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick tip I learned this weekend on how to get all your RubyGems installed without documentation by default.<br />
<span id="more-609"></span><br />
I knew there was a way to prevent documentation from being installed at the command line with the &#8211;no-rdoc &#8211;no-ri options:</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">$ gem install rails --no-rdoc --no-ri</pre></div></div>

<p>But there&#8217;s another way to prevent documentation from being installed. Create a .gemrc file in your home directory with the following:</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">gem: --no-ri --no-rdoc</pre></div></div>

<p>Now you don&#8217;t have to worry about supplying the command line options, this will give you no documentation by default.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunambrose.com/2011/10/24/how-to-install-gems-without-documentation-by-default/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting VIM setup for Ruby on Rails</title>
		<link>http://www.shaunambrose.com/2011/10/03/getting-vim-setup-for-ruby-on-rails/</link>
		<comments>http://www.shaunambrose.com/2011/10/03/getting-vim-setup-for-ruby-on-rails/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 03:39:31 +0000</pubDate>
		<dc:creator>Shaun</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.shaunambrose.com/?p=552</guid>
		<description><![CDATA[I just got started using Vim for Ruby on Rails development. To me, learning Vim is like growing a garden, it doesn&#8217;t happen overnight and you have to keep working at it. Also, getting Vim setup isn&#8217;t a one-and-done activity like installing a new toilet or a traditional editor/IDE. You have to keep tweaking and [...]]]></description>
			<content:encoded><![CDATA[<p>I just got started using Vim for Ruby on Rails development. To me, learning Vim is like growing a garden, it doesn&#8217;t happen overnight and you have to keep working at it. Also, getting Vim setup isn&#8217;t a one-and-done activity like installing a new toilet or a traditional editor/IDE. You have to keep tweaking and customizing it. Anyway, here are some of my notes on how I got started and some quick wins. Please note that this is more of a (rough) guide on how to get Vim setup for Ruby on Rails than it is how to use it. </p>
<p><span id="more-552"></span></p>
<h3>Get Vim</h3>
<p>First the easy part, download and install your flavor of Vim: <a href="http://www.vim.org/download.php">http://www.vim.org/download.php</a></p>
<h3>Vimrc file</h3>
<p>Now, before you start editing any files, you&#8217;ll probably want to create a vimrc file. You&#8217;ll be spending a lot of time in here, this is where most of you preferences and customizations for Vim will go. This file is like using a Vim performance enhancer. Tweaking this file will turn your normal ride into a high performance sports car. But to me, simply copying someone else&#8217;s vimrc file is like getting into someone else&#8217;s car where you have to adjust the seat, mirrors, steering wheel, radio presets, etc. because it&#8217;s customized for them, not you. And with my brief experience with Vim, it&#8217;s unlikely that you&#8217;re going to find a vimrc file that is exactly what you want. So you have to customize it. Below are some links on creating and customizing your vimrc file.</p>
<p>Information on the vimrc file: <a href="http://www.derekwyatt.org/vim/the-vimrc-file/">http://www.derekwyatt.org/vim/the-vimrc-file/</a></p>
<p>More basic info: <a href="http://vim.wikia.com/wiki/Open_vimrc_file">http://vim.wikia.com/wiki/Open_vimrc_file</a></p>
<p>Here&#8217;s a good thread on Stack Overflow to find good settings for your vimrc file:<br />
<a href="http://stackoverflow.com/questions/164847/what-is-in-your-vimrc">http://stackoverflow.com/questions/164847/what-is-in-your-vimrc</a></p>
<p>You can use <a href="http://www.vimbits.com/">vimbits.com</a> to handpick vimrc settings.</p>
<p>You can browse and cherry-pick from other people&#8217;s vimrc files on GitHub, by using a search query like this in Google: <a href="http://www.google.com/search?q=.vimrc+site%3Agithub.com">&#8220;.vimrc site:github.com&#8221;</a></p>
<p>Here is an online resource for all vimrc options (which is the same as the built-in documenation):<br />
<a href="http://vimdoc.sourceforge.net/htmldoc/quickref.html#option-list">http://vimdoc.sourceforge.net/htmldoc/quickref.html#option-list</a></p>
<p>If you want to know what a certain vimrc option does, just type: &#8216;:help option-name&#8217; and it will tell you what it does and what the long and short form of the option is.</p>
<p>Learn more about the different key mappings:<br />
<a href="http://stackoverflow.com/questions/3776117/vim-what-is-the-difference-between-the-remap-noremap-nnoremap-and-vnoremap-ma">http://stackoverflow.com/questions/3776117/vim-what-is-the-difference-between-the-remap-noremap-nnoremap-and-vnoremap-ma</a></p>
<p>Learn more about the &lt;leader&gt; character:<br />
<a href="http://stackoverflow.com/questions/1764263/what-is-the-leader-in-a-vimrc-file">http://stackoverflow.com/questions/1764263/what-is-the-leader-in-a-vimrc-file</a></p>
<h3>Set a default color scheme and font</h3>
<p>Now that you have a basic vimrc file setup, here&#8217;s a quick and easy win to customize your Vim experience by picking a default color scheme and font.</p>
<p>Here are some good color themes I have found:</p>
<ul>
<li><strong>jellybeans:</strong> <a href="http://www.vim.org/scripts/script.php?script_id=2555">http://www.vim.org/scripts/script.php?script_id=2555</a></li>
<li><strong>railscasts:</strong> <a href="http://www.vim.org/scripts/script.php?script_id=2175">http://www.vim.org/scripts/script.php?script_id=2175</a></li>
<li><strong>vividchalk:</strong> <a href="http://www.vim.org/scripts/script.php?script_id=1891">http://www.vim.org/scripts/script.php?script_id=1891</a></li>
</ul>
<p>The color theme files go in ~/.vim/colors or ~\vimfiles\colors if you&#8217;re on Windows. Then you in your vimrc file you can set your default color scheme:</p>
<pre>
<code>
" Set default color scheme
colorscheme jellybeans
</code>
</pre>
<p>It&#8217;s also nice  to have a good programming font in Vim. Here&#8217;s a list of preferred fonts and also how to set a default font in your vimrc file:</p>
<p><a href="http://stackoverflow.com/questions/485174/programming-fonts">http://stackoverflow.com/questions/485174/programming-fonts</a><br />
<a href="http://vim.wikia.com/wiki/Change_font">http://vim.wikia.com/wiki/Change_font</a></p>
<h3>Install plug-ins</h3>
<p>Next, you&#8217;ll probably want to install some plug-ins to add additional functionality to Vim. There are two main ways (I know of) to manage your plug-ins: <a href="https://github.com/tpope/vim-pathogen">Pathogen</a> and <a href="https://github.com/gmarik/vundle">Vundle</a>. Personally, I use Vundle, I like how you can keep track of all your plug-ins in your vimrc file and run one command to install them all, kinda like Bundler. Anyway, here are some handy plug-ins that I have discovered so far:</p>
<ul>
<li><a href="https://github.com/tpope/vim-rails">https://github.com/tpope/vim-rails</a></li>
<li><a href="https://github.com/tpope/vim-endwise">https://github.com/tpope/vim-endwise</a></li>
<li><a href="https://github.com/tpope/vim-fugitive">https://github.com/tpope/vim-fugitive</a></li>
<li><a href="https://github.com/scrooloose/nerdtree">https://github.com/scrooloose/nerdtree</a></li>
<li><a href="https://github.com/tpope/vim-surround">https://github.com/tpope/vim-surround</a></li>
<li><a href="https://github.com/lucapette/vim-ruby-doc.git">https://github.com/lucapette/vim-ruby-doc.git</a></li>
<li><a href="https://github.com/vim-scripts/YankRing.vim.git">https://github.com/vim-scripts/YankRing.vim.git</a></li>
<li><a href="https://github.com/wincent/Command-T">https://github.com/wincent/Command-T</a></li>
</ul>
<h3>Summary</h3>
<p>Well, that&#8217;s about it. Definitely not an exhaustive guide, but hopefully it&#8217;s enough to get started. Like I said I just got started using Vim for Ruby on Rails myself, so I know there&#8217;s a lot of plug-ins and settings I haven&#8217;t discovered yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunambrose.com/2011/10/03/getting-vim-setup-for-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Methods in Ruby</title>
		<link>http://www.shaunambrose.com/2011/08/18/quick-tip-methods-in-ruby/</link>
		<comments>http://www.shaunambrose.com/2011/08/18/quick-tip-methods-in-ruby/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 05:29:05 +0000</pubDate>
		<dc:creator>Shaun</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.shaunambrose.com/?p=548</guid>
		<description><![CDATA[Here are some quick tips to keep in mind when coding new methods in Ruby. Each method should be short and focused on doing one thing. Each method should be well named, the method name should reflect what the method does. Each method should operate at a single conceptual level. Methods shouldn&#8217;t be doing both [...]]]></description>
			<content:encoded><![CDATA[<p>Here are some quick tips to keep in mind when coding new methods in Ruby.<br />
<span id="more-548"></span></p>
<li>Each method should be short and focused on doing one thing.</li>
<li>Each method should be well named, the method name should reflect what the method does.</li>
<li>Each method should operate at a single conceptual level. Methods shouldn&#8217;t be doing both low level logic and high level logic.</li>
<p>I&#8217;ve learned that keeping your Ruby methods well named, short and focused makes them easier to read and also easier to test.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunambrose.com/2011/08/18/quick-tip-methods-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: How to use unless in Ruby</title>
		<link>http://www.shaunambrose.com/2011/04/22/quick-tip-how-to-use-unless-in-ruby/</link>
		<comments>http://www.shaunambrose.com/2011/04/22/quick-tip-how-to-use-unless-in-ruby/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 21:44:14 +0000</pubDate>
		<dc:creator>Shaun</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[how to]]></category>

		<guid isPermaLink="false">http://www.shaunambrose.com/?p=531</guid>
		<description><![CDATA[Unless is a backwards if in Ruby. For the longest time I had a hard time wrapping my head around using it instead of just using not if, which I&#8217;ve always been used to. But, if you want to be apart of the Ruby culture, you need to learn how to use unless, here&#8217;s my [...]]]></description>
			<content:encoded><![CDATA[<p><em>Unless</em> is a backwards <em>if</em> in Ruby. For the longest time I had a hard time wrapping my head around using it instead of just using <em>not if</em>, which I&#8217;ve always been used to. But, if you want to be apart of the Ruby culture, you need to learn how to use <em>unless</em>, here&#8217;s my simple technique on how I learned to use it.<br />
<span id="more-531"></span><br />
When I first started using <em>unless</em>, I just translated it (in my mind) with the dictionary definition: except on the condition that. You can even shorten the translation to: except if. Once I did this, reading and using <em>unless</em> made more sense to me.</p>
<p>Example:</p>
<pre>
<code>messages.delete('twitter') unless user.twitter_username</code>
</pre>
<p>Using the translation, this Ruby code would read as: delete twitter messages except if the user has a twitter username.</p>
<p>Using and reading <em>unless</em> in Ruby was like Greek to me when I first saw it, but now that my brain automatically makes the association/translation for me, using it has become second nature.</p>
<p>Hopefully this technique will help someone else struggling to use <em>unless</em> in Ruby.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunambrose.com/2011/04/22/quick-tip-how-to-use-unless-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix the &#8220;msvcrt-ruby18.dll is missing from your computer&#8221; error message in Ruby on Rails</title>
		<link>http://www.shaunambrose.com/2010/11/11/how-to-fix-the-msvcrt-ruby18-dll-is-missing-from-your-computer-error-message-in-ruby-on-rails/</link>
		<comments>http://www.shaunambrose.com/2010/11/11/how-to-fix-the-msvcrt-ruby18-dll-is-missing-from-your-computer-error-message-in-ruby-on-rails/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 19:09:30 +0000</pubDate>
		<dc:creator>Shaun</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.shaunambrose.com/?p=465</guid>
		<description><![CDATA[Here&#8217;s how to fix that annoying Ruby on Rails popup message: &#8220;The program can&#8217;t start because msvcrt-ruby18.dll is missing from your computer. Try reinstalling the program to fix this problem.&#8221; This fix applies if you&#8217;re using cucumber on Windows. It turns out the error message is related to the json gem that cucumber depends on. [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to fix that annoying Ruby on Rails popup message: &#8220;The program can&#8217;t start because msvcrt-ruby18.dll is missing from your computer. Try reinstalling the program to fix this problem.&#8221;</p>
<p>This fix applies if you&#8217;re using cucumber on Windows.<br />
<span id="more-465"></span><br />
It turns out the error message is related to the json gem that cucumber depends on. The details and solution are buried in this <a href="http://groups.google.com/group/rubyinstaller/browse_thread/thread/7f96baf7e80d30d8/3145b2ea94697e44">thread</a>.</p>
<p>To fix it, you just have to run:</p>
<pre>
<code>
gem uninstall json</code></pre>
<p>followed by:</p>
<pre>
<code>
gem install json --platform=ruby
</pre>
<p></code></p>
<p>Notes:<br />
You need to have DevKit installed for this fix: <a href="https://github.com/oneclick/rubyinstaller/wiki/Development-Kit">https://github.com/oneclick/rubyinstaller/wiki/Development-Kit</a></p>
<p>If you get an error when installing the new json gem, make sure a rails server or console isn't running in the background.</p>
<p>The offending version of json for me was 1.4.6-x86-mingw32, so you need to uninstall and install that version: gem install json --version=1.4.6 --platform=ruby</p>
<p>If you install new gems after you make this fix, the error message will pop-up again, so you'll have to uninstall/install the json gem again. If anyone knows a way around this, please let me know.</p>
<p>Anyway, I hope this fix is helpful, that error was driving me nuts!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunambrose.com/2010/11/11/how-to-fix-the-msvcrt-ruby18-dll-is-missing-from-your-computer-error-message-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>How to fix a “sqlite3.dll missing” error message in Ruby on Rails</title>
		<link>http://www.shaunambrose.com/2010/08/05/how-to-fix-a-sqlite3-dll-missing-error-message-in-ruby-on-rails/</link>
		<comments>http://www.shaunambrose.com/2010/08/05/how-to-fix-a-sqlite3-dll-missing-error-message-in-ruby-on-rails/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 20:10:35 +0000</pubDate>
		<dc:creator>Shaun</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[how to]]></category>

		<guid isPermaLink="false">http://www.shaunambrose.com/?p=433</guid>
		<description><![CDATA[Here&#8217;s a little reminder for myself on how I fixed the &#8220;sqlite3.dll missing&#8221; error message I was getting while setting up a new Ruby on Rails environment. First, I downloaded the latest SQlite3 DLL. (I grabbed the DLL of the SQLite library without the TCL bindings.) Then, I exracted the .dll and .def files to [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little reminder for myself on how I fixed the &#8220;sqlite3.dll missing&#8221; error message I was getting while setting up a new Ruby on Rails environment.<br />
<span id="more-433"></span></p>
<p>First, I downloaded the latest <a href="http://www.sqlite.org/download.html">SQlite3 DLL.</a> (I grabbed the DLL of the SQLite library without the TCL bindings.)</p>
<p>Then, I exracted the .dll and .def files to my C:\ruby\bin directory and that fixed my issue. (You&#8217;ll might have to restart your console session.) </p>
<p>These steps will also fix this error message:<br />
&#8220;The procedure entry point sqlite3_column_database_name could not be located in the dynamic link library sqlite3.dll.&#8221;</p>
<p>Hope this helps someone else running into the same issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunambrose.com/2010/08/05/how-to-fix-a-sqlite3-dll-missing-error-message-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>How to create migrations in Ruby on Rails that only run in the development enviroment</title>
		<link>http://www.shaunambrose.com/2010/02/13/how-to-create-migrations-in-ruby-on-rails-that-only-run-in-the-development-enviroment/</link>
		<comments>http://www.shaunambrose.com/2010/02/13/how-to-create-migrations-in-ruby-on-rails-that-only-run-in-the-development-enviroment/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 06:52:17 +0000</pubDate>
		<dc:creator>Shaun</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[how to]]></category>

		<guid isPermaLink="false">http://www.shaunambrose.com/?p=371</guid>
		<description><![CDATA[This is a reminder for myself for when I want to use a migration to create test data for the development environment only. I thought it would be as easy as using the environment variable ENV['RAILS_ENV'] in the migration to see which environment you&#8217;re in, but this doesn&#8217;t work. After a little searching, it is [...]]]></description>
			<content:encoded><![CDATA[<p>This is a reminder for myself for when I want to use a migration to create test data for the development environment only.<br />
<span id="more-371"></span><br />
I thought it would be as easy as using the environment variable <strong>ENV['RAILS_ENV']</strong> in the migration to see which environment you&#8217;re in, but this doesn&#8217;t work. After a little searching, it is as easy as I thought; you just have to use the constant <strong>RAILS_ENV</strong>. So, your migration would look something like this:</p>
<pre><code>
def self.up
  if RAILS_ENV == 'development'
    # set all of your test data for development...
  end
end
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunambrose.com/2010/02/13/how-to-create-migrations-in-ruby-on-rails-that-only-run-in-the-development-enviroment/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

