<?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>BSharpe dot com &#187; Rails</title>
	<atom:link href="http://bsharpe.com/category/rails/feed" rel="self" type="application/rss+xml" />
	<link>http://bsharpe.com</link>
	<description></description>
	<lastBuildDate>Thu, 23 Feb 2012 14:05:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Optimize your Rails environment on OS X</title>
		<link>http://bsharpe.com/rails/optimize-your-rails-environment-on-os-x</link>
		<comments>http://bsharpe.com/rails/optimize-your-rails-environment-on-os-x#comments</comments>
		<pubDate>Wed, 17 Mar 2010 23:21:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Gems]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://bsharpe.com/?p=3</guid>
		<description><![CDATA[Getting your development environment setup just the way you like it takes some time.   I&#8217;ve done it several times recently and this is the setup I feel most productive with. The Basics While I could talk you through the whole &#8230; <a href="http://bsharpe.com/rails/optimize-your-rails-environment-on-os-x">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Getting your development environment setup just the way you like it takes some time.   I&#8217;ve done it several times recently and this is the setup I feel most productive with.<br />
<span id="more-3"></span></p>
<h2>The Basics</h2>
<p>While I could talk you through the whole enchilada.  Robby Russell over at Planet Argon <a href="http://www.robbyonrails.com/articles/2010/02/08/installing-ruby-on-rails-passenger-postgresql-mysql-oh-my-zsh-on-snow-leopard-fourth-edition" target="_blank">has already done this</a>.  He&#8217;s done an excellent job of updating this guide over the years, and it&#8217;s usually the first place I go with a new installation.   Someday, I&#8217;m sure I&#8217;ll have it memorized.</p>
<h2>Ruby</h2>
<p>While you can use the built-in ruby on Snow Leopard, I like to look forward to the day when we&#8217;re all 30% faster simply by deploying on Ruby 1.9.  I use it in development for that very reason.  However, most clients like to use Ruby Enterprise Edition because it&#8217;s so efficient and stable.  Therefore, we need to switch between versions easily.   Enter the <a href="http://rvm.beginrescueend.com/" target="_blank">Ruby Version Manager</a>.</p>
<pre class="brush:bash">&gt;sudo gem install rvm</pre>
<p>RVM not only keeps your system clean, but it allows for easy switching between versions of ruby.</p>
<p>For most cases I like to use the <a href="http://www.rubyenterpriseedition.com/" target="_blank">Ruby Enterprise Edition</a> for it&#8217;s efficiency as my default ruby.</p>
<pre class="brush:bash">&gt;rvm install ree
&gt;rvm use ree --default</pre>
<p>But I also like to have Ruby 1.9 around for the speed.</p>
<pre class="brush:bash">&gt;rvm install 1.9.1</pre>
<h2>Gems</h2>
<p>Make sure rubygems is up to date.</p>
<pre class="brush:bash">&gt;gem update --system</pre>
<p>Edit your ~/.gemrc file to contain something like the following:</p>
<pre class="brush:text">---
gem: --no-ri --no-rdoc
:benchmark: false
:backtrace: false
:update_sources: true
:verbose: true
:bulk_threshold: 1000
:sources:
- http://gems.rubyforge.org</pre>
<p>The most important reason to do this is for that second line.  It stops gem from installing the ri and rdoc documentation which I never use anyway.  This speeds up gem installation considerably.</p>
<p>Since we&#8217;re using RVM which keeps separate gem directories for each version of Ruby, you&#8217;ll need to install a few gems. (Even if you went through this from Robby&#8217;s instructions)</p>
<p>The most basic gems first:</p>
<pre class="brush:bash">&gt;gem install rails mongrel</pre>
<p>and then the gems for the DB:</p>
<pre class="brush:bash">&gt;gem install pg</pre>
<p>and some convience gems:</p>
<pre class="brush:bash">&gt;gem install hirb wirble</pre>
<p>And some optional but useful gems:</p>
<pre class="brush:bash">&gt;gem install haml compass thin cheat</pre>
<p><a href="http://haml-lang.com/" target="_blank">Haml</a> is a huge HTML productivity booster.<br />
<a href="http://wiki.github.com/chriseppstein/compass/" target="_blank"> Compass</a> (and Blueprint) is a huge CSS productivity booster.<br />
<a href="http://code.macournoyer.com/thin/" target="_blank"> Thin</a> is a super-fast webserver for testing and such (doesn&#8217;t tail the log like mongrel or webrick).<br />
<a href="http://cheat.errtheblog.com/" target="_blank"> Cheat</a> is an awesome command-line tool.  If I had a nickle for everytime i&#8217;ve typed:</p>
<pre class="brush:bash">&gt;cheat strftime</pre>
<p>I&#8217;d be rich.</p>
<h2>Tweaks</h2>
<p>Put a file in your home directory called .irbrc and have it include the following:</p>
<pre class="brush:ruby">require 'irb/completion'

# History
#require 'irb/ext/save-history'  #wirble does history
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"

# Wirble is a plugin to colorize your irb, it's installed from a gem (gem install -y wirble)
require 'rubygems'
begin
  # load wirble
  require 'wirble'

  # start wirble (with color)
  Wirble.init
  Wirble.colorize
rescue LoadError =&gt; err
  warn "Couldn't load Wirble: #{err}"
end

ARGV.concat ["--readline", "--prompt-mode", "simple"]

# autoindent of code while typing it
IRB.conf[:AUTO_INDENT]=true

# Log to STDOUT if in Rails &amp;&amp; use HIRB if available
if ENV.include?('RAILS_ENV') &amp;&amp; !Object.const_defined?('RAILS_DEFAULT_LOGGER')
  begin
    require 'hirb'
    Hirb.enable
  rescue LoadError =&gt; err
    warn "No Hirb: #{err}"
  end
  require 'logger'
  RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end

# Easily print methods local to an object's class
class Object
  def local_methods
    (methods - Object.instance_methods).sort
  end
end

# copy a string to the clipboard
def pbcopy(string)
  `echo "#{string}" | pbcopy`
  string
end</pre>
<p>This turns on Hirb/Wirble for the ruby console as well as colorization, history and redirecting the logger to the console for Rails.  This is very handy to see what Rails is doing with your database while you&#8217;re issuing commands in the console.</p>
<p>And lastly, some handy Bash aliases that really help speed up Rails work.</p>
<pre class="brush:bash"># Rails 1.0+
alias ss='script/server'
alias sc='script/console'
alias sg='script/generate'
alias sp='script/plugin'
alias tdl='tail -f log/development.log'
# Rails 2.0+
alias sdb='script/dbconsole'
# Rails 3.0+
alias sr='script/rails'
# Passenger
alias rr='touch tmp/restart.txt'

# Useful Git aliases
alias gst='git status'
alias gl='git pull'
alias gp='git push'
alias gdm='git diff | mate'
alias gc='git commit -v'
alias gcam='git commit -v -a -m'
alias gb='git branch --color'
alias gba='git branch --color -a'
alias gaa='git add .'
alias gco='git checkout'
alias gsp='git svn dcommit'
alias gsl='git svn rebase'
alias gsf='git svn fetch'</pre>
<h2>Appendix A: Use the OS X Dictionary for Rails Documentation.</h2>
<p><a href="http://priithaamer.com/blog/ruby-on-rails-dictionary-for-macosx" target="_blank">Priit Haamer created a OS X dictionary file of the Rails API documentation</a> which is oh so handy.  I use it constantly as it&#8217;s faster that firing up a browser and works anywhere (with or without interweb access).</p>
<h2>Conclusion</h2>
<p>I hope this helps you get optimized with your Rails development.   Please let me know if you have additions or need clarification on some of the items here.</p>
]]></content:encoded>
			<wfw:commentRss>http://bsharpe.com/rails/optimize-your-rails-environment-on-os-x/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

