<?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>Strange Symphonies &#187; RubyGems</title>
	<atom:link href="http://blog.aizatto.com/tag/rubygems/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.aizatto.com</link>
	<description>Don't worry, be happy</description>
	<lastBuildDate>Sun, 25 Jul 2010 07:59:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Ruby on Rails Finite State Machine Plugin: Workflow</title>
		<link>http://blog.aizatto.com/2009/12/07/ruby-on-rails-finite-state-machine-plugin-workflow/</link>
		<comments>http://blog.aizatto.com/2009/12/07/ruby-on-rails-finite-state-machine-plugin-workflow/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 17:54:03 +0000</pubDate>
		<dc:creator>aizatto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Finite State Machine]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[RubyGems]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://blog.aizatto.com/?p=3125</guid>
		<description><![CDATA[I've been using the acts_as_state_machine plugin for Ruby on Rails for ages, but I thought it was time I look for alternatives, to see if there has been any development in the Finite State Machine scene. I also started getting worried that even though acts_as_state_machine still works, development on it has pretty much been discontinued. [...]]]></description>
			<content:encoded><![CDATA[<p>I've been using the <a href="http://blog.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/">acts_as_state_machine plugin for Ruby on Rails</a> for ages, but I thought it was time I look for alternatives, to see if there has been any development in the Finite State Machine scene.  I also started getting worried that even though <code>acts_as_state_machine</code> still works, development on it has pretty much been discontinued. Good or bad, you can't really say.</p>
<p>Lucky me. I found one, and a pretty great one.</p>
<p>Introducing <a href="http://github.com/geekq/workflow">Workflow</a>, your alternate Finite State Machine for Ruby on Rails.</p>
<h3><code>acts_as_state_machine</code> vs Workflow</h3>

<p>At its core acts_as_state_machine and Workflow function exactly the same way. Feature wise Workflow wins out as it makes it easier to manage the callbacks. Workflow is more up to date, and I personally prefer its syntax a lot better than acts_as_state_machine.</p>
<p>Workflow's syntax looks a lot more like a Domain Specific Language.</p>
<h3>Installing Workflow</h3>

<h4>Installing Workflow as a Ruby on Rails Plugin</h4>

<p>Workflow can be installed either via Ruby Gems or a Ruby on Rails plugin.</p>
<p>As a Ruby on Rails plugin, go to the root folder of your Rails application and execute:</p>
<pre class="brush: plain;">./script/plugin install \
     git://github.com/geekq/workflow.git</pre>
<p class="block_important"><strong>Note:</strong> You may need Git installed </p>
<h4>Installing Workflow via Ruby Gems</h4>

<p>Likewise as a Ruby Gem, Workflow can be easily installed.  As your root user execute:</p>
<pre class="brush: plain;">gem install workflow</pre>
<p>We will need to update your <code>config/environments.rb</code>, and in the <code>Rails::Initializer.run</code> block we will need to add in <code>config.gem 'workflow'</code>.</p>
<p>Your <code>config/environments.rb</code> may look like so:</p>
<pre class="brush: ruby;">
Rails::Initializer.run do |config|
  ...
  config.gem 'workflow'
  ..
end
</pre>
<h3>Using Workflow</h3>

<p>Lets have a look at a sample code, featuring a Person.</p>
<pre class="brush: ruby;">
class Person &lt; ActiveRecord::Base
  include Workflow
  workflow do
    state :sleeping do
      event :shower, :transitions_to =&gt; :showering
      event :work, :transitions_to =&gt; :working
    end

    state :showering do
      event :sleep, :transitions_to =&gt; :sleeping
      event :work, :transitions_to =&gt; :working
      event :date, :transitions_to =&gt; :dating do |romantic_interest|
        successful = self.flirt(romantic_interest)
        halt unless successful
      end
    end

    state :working do
      event :shower, :transitions_to =&gt; :showering
    end

    state :dating do
      event :shower, :transitions_to =&gt; :showering
      event :sleep, :transitions_to =&gt; :showering
      event :work, :transitions_to =&gt; :showering
    end
  end
end
</pre>
<p class="block_important"><strong>Note:</strong> Workflow makes the assumption that the state of your model is saved in a field called <code>workflow_state</code>. </p>
<p>In <strong>line 2</strong> we have to specifically include include Workflow into our model. From there we begin describing the workflow by opening up a <code>workflow</code> block. Inside we define what states the model is going to contain, and what events can be fired to transition the model from one state to another.</p>
<p>The <strong>initial state of a model is the first state defined</strong>, in this case it is the <code>sleeping</code> state. States are defined in a <code>state</code> block as seen on <strong>lines 4, 9, 17, and 23</strong>. We have four states here: <code>sleeping</code>, <code>working</code>, <code>showering</code>, <code>dating</code>. Possible events a state may fire are contained within the <code>state</code> block as an <code>event</code> method. These events describe which state they would transition to if they were fired.</p>
<p>Methods are created every time you define a <code>state</code> or <code>event</code>. The method created when you define is a state tests wether or not the state is within a particular state, ie <code>person.sleeping?</code>. The methods created when you define an event is the event itself, ie <code>person.sleep!</code>.</p>
<p>There is also an additional method <code>current_state</code>, where you can investigate the current state of the object.</p>
<p>Given our example model above, these methods were created for our model:</p>
<p><code></p>
<ul>
<li>sleeping?</li>
<li>showering?</li>
<li>working?</li>
<li>dating?</li>
<li>sleep!</li>
<li>work!</li>
<li>shower!</li>
<li>date!</li>
<li>current_state</li>
</ul>
<p></code></p>
<h3>Events</h3>

<p>Events help you to transition from one state to another. So suppose your person is sleeping, and you want him to shower, well we'll just call shower!.</p>
<pre class="brush: ruby;">
person.current_state # &quot;sleeping&quot;
person.shower!
person.current_state # &quot;showering&quot;
</pre>
<p class="block_important"><strong>Note:</strong> When firing an event, Workflow calls <code>ActiveRecord::Base.update_attribute</code>. This means that <strong>only your record's state will be saved in the database</strong>, any other changes to the record are not. You still have to call <code>ActiveRecord::Base.save</code>. It also <strong>doesn't call any validations.</strong> Validations will be handled by your guards, which will be discussed later. Calling an event from a new unsaved record, will save the record into the database. </p>
<h3>Event Arguments</h3>

<p>You can even have your events accept arguments, this can be see on <strong>line 12</strong>, in the <code>:date</code> block.</p>
<pre class="brush: ruby; first-line: 12;">
    state :showering do
      event :sleep, :transitions_to =&gt; :sleeping
      event :work, :transitions_to =&gt; :working
      event :date, :transitions_to =&gt; :dating do |romantic_interest|
        successful = self.flirt(romantic_interest)
        halt unless successful
      end
    end
</pre>
<p class="block_important"><strong>Note:</strong> The scope of the block is within the instance. Treat it as any other method. <code>self</code> refers to the instance itself. <code>flirt</code> is a method defined in the instance. You would have to define the <code>flirt</code> method yourself. </p>
<p>Lets have a look at an example:</p>
<pre class="brush: ruby;">
person.current_state # showering

romantic_interest = Person.new
person.date! romantic_interest
person.current_state # dating
</pre>
<p>With events being able to accept arguments, this gives us a wider range of flexibility on handling and organizing the flow of your model. But they can get more powerful with callbacks.</p>
<h3>Callbacks</h3>

<p>A <code>state</code> also includes two callbacks. One for entering the state, and one for exiting the state.</p>
<p>Like the <code>event</code> blocks, the callback blocks also accept arguments.</p>
<p>You can define a <code>state</code>'s callback like so:</p>
<pre class="brush: ruby;">
state :sleeping do
  event :shower, :transitions_to =&gt; :showering
  event :work, :transitions_to =&gt; :working

  on_entry do |prior_state, triggering_event, *event_args|
    # code
  end

  on_exit do |new_state, triggering_event, *event_args|
    # code
  end
end
</pre>
<ul>
<li>The <code>on_entry</code> callback is called <strong>when a person enters the sleeping state</strong>.</li>
<li>The <code>on_exit</code> callback is called <strong>when a person exits the sleeping state</strong>.</li>
</ul>
<p>You can also define your callbacks outside of the <code>state</code> block and in your model itself as methods:</p>
<pre class="brush: ruby;">
state :sleeping do
  event :shower, :transitions_to =&gt; :showering
  event :work, :transitions_to =&gt; :working
end

def on_sleeping_entry(prior_state, triggering_event, *event_args)
  # code
end

def on_sleeping_exit(new_state, triggering_event, *event_args)
  # code
end
</pre>
<p class="block_important"><strong>Note:</strong> Notice the naming convention of the method name? To use this method, the callback is called <code>on_ + state name + _entry</code>, and <code>on_ + state name + _entry</code>. </p>
<p><strong>The arguments for the block and method are optional.</strong> Therefore for clarity, you may just enter:</p>
<pre class="brush: ruby;">
state :sleeping do
  event :shower, :transitions_to =&gt; :showering
  event :work, :transitions_to =&gt; :working

  on_entry do
    # code
  end

def on_sleeping_exit(new_state, triggering_event, *event_args)
  # code
end
</pre>
<h4>Global Callback</h4>

<p>This gets tedious if you want to monitor the transitions of every state change.  Don't worry, Workflow can handle that.</p>
<p>Workflow comes with an <code>on_transition</code> callback which is placed inside the <code>workflow</code> block:</p>
<pre class="brush: ruby;">
workflow do
  on_transition do |from, to, triggering_event, *event_args|
    puts &quot;from #{from} to #{to} via #{triggering_event}&quot;
  end
end
</pre>
<h4>Callback Order</h4>

<p>With all these callbacks, it gets a bit confusing. Here are <strong>Workflow's callbacks in context of ActiveRecord's callbacks</strong>:</p>
<ul>
<li>Workflow's in event</li>
<li>Workflow's on_transition</li>
<li>Workflow's on_exit</li>
<li>ActiveRecord::Base.before_save</li>
<li>ActiveRecord::Base.save</li>
<li>ActiveRecord::Base.after_save</li>
<li>Workflow's on_entry</li>
</ul>
<h3>Guarding States: halt!</h3>

<p>Using Workflow your model's validations do not work when an event is fired. In fact, only the model's <code>workflow_state</code> is saved when an event is fired, and not any other data.</p>
<p>In Workflow we can setup a guard, or a <code>halt</code>. This will prevent the transition from ever occurring, and provide us with the safety of having our models validated.</p>
<p>Guards can only be used inside the event block itself.  For example:</p>
<pre class="brush: ruby; first-line: 12;">
    state :showering do
      event :date, :transitions_to =&gt; :dating do |romantic_interest|
        successful = self.flirt(romantic_interest)
        halt unless successful
      end
    end
</pre>
<p>Assuming that the flirting with the romantic interest was unsuccessful, the person would still be in the the showering state.  All thanks to the <code>halt</code> on <strong>line 15</strong>.</p>
<p>This would run as follows:</p>
<pre class="brush: ruby;">
person.current_state # showering

romantic_interest = Person.new
person.date! romantic_interest
person.current_state # showering
</pre>
<p>Instead of just a <code>halt</code>, you can make it more destructive by calling <code>halt!</code> (with an exclamation mark) instead, which will throw the <code>Workflow::TransitionHalted</code> Exception instead.</p>
<h3>Conclusion</h3>

<p>As you can see Workflow is quite feature rich, and provides more flexibility than acts_as_state_machine. I would recommend using this over acts_as_state_machine any day. So why don't you experiment with it, and have some fun?</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.aizatto.com/2009/11/26/finder-for-workflow-states/" title="Finder for Workflow States (November 26, 2009)">Finder for Workflow States</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/" title="Ruby on Rails Finite State Machine Plugin: acts_as_state_machine (May 24, 2007)">Ruby on Rails Finite State Machine Plugin: acts_as_state_machine</a> (9)</li>
	<li><a href="http://blog.aizatto.com/2007/05/23/why-i-support-free-culture/" title="Why I Support Free Culture (May 23, 2007)">Why I Support Free Culture</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2009/11/11/swfupload-on-rails/" title="SWFUpload on Rails (November 11, 2009)">SWFUpload on Rails</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2009/09/12/ruby-on-rails-git-pre-commit-hook/" title="Ruby on Rails git pre-commit hook (September 12, 2009)">Ruby on Rails git pre-commit hook</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.aizatto.com/2009/12/07/ruby-on-rails-finite-state-machine-plugin-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>autotest-ting your Rails Application with Visual and Audio Feedback using Growl and mpg321</title>
		<link>http://blog.aizatto.com/2007/11/19/autotest-ting-your-rails-application-with-visual-and-audio-feedback-using-growl-and-mpg321/</link>
		<comments>http://blog.aizatto.com/2007/11/19/autotest-ting-your-rails-application-with-visual-and-audio-feedback-using-growl-and-mpg321/#comments</comments>
		<pubDate>Sun, 18 Nov 2007 17:46:30 +0000</pubDate>
		<dc:creator>aizatto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Apple Mac OS X]]></category>
		<category><![CDATA[Autotest]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Growl]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Rake]]></category>
		<category><![CDATA[RubyGems]]></category>
		<category><![CDATA[ZenTest]]></category>

		<guid isPermaLink="false">http://rails.aizatto.com/2007/11/19/autotest-ting-your-rails-application-with-visual-and-audio-feedback-with-growl-and-mpg321/</guid>
		<description><![CDATA[autotest is a commandline tool that comes packaged together with ZenTest. Designed to continually test your Rails application, autotest makes a slight notch easier by removing the need to repeatedly call the rake task to run your application's various tests. autotest is actually in the ZenTest gem. sudo gem install -y ZenTest Go to your [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.zenspider.com/ZSS/Products/ZenTest/#rsn">autotest</a> is a commandline tool that comes packaged together with <a href="http://www.zenspider.com/ZSS/Products/ZenTest/">ZenTest</a>.  Designed to continually test your Rails application, <code>autotest</code> makes a slight notch easier by removing the need to repeatedly call the rake task to run your application's various tests.</p>
<p class="block_important"><strong>Note:</strong> autotest is not limited to the default Ruby <code>Test::Unit::TestCase</code>.  It will even work out of the box with <a href="http://rspec.rubyforge.org">RSpec</a>. </p>
<h3>Installing autotest</h3>

<p><code>autotest</code> is actually in the ZenTest gem.</p>
<pre class="brush: plain; gutter: false;">sudo gem install -y ZenTest</pre>
<p>Go to your application root directory and run <code>autotest</code> and watch it go!</p>
<pre class="brush: plain; gutter: false;">autotest</pre>
<p>Dead simple right? But still slightly irritating having to switch back to the terminal to see the results of test.  So lets spruce it up a little, lets make it notify us of the results.</p>
<h3>Visual Feedback with Growl</h3>

<p><a href="http://www.growl.info">Growl</a> is a notification that is over layed on top of your desktop, so that other applications are able to notify/inform you of anything, generally updates.  For example <a href="http://www.adiumx.com/">Adium</a> uses it to notify you of people logging in or out.</p>
<p class="block_important"><strong>Note:</strong> Growl is a Mac OS X application.  For other platforms you'll have to look at integration with their notification apps, for example <code>knotify</code>, or <code>gnome-notification</code>. </p>
<p>Combined together with Growl, you will continuously be notified of the current status of your test suite through a nice non disruptive interface.  Thus helping to ensure the integrity of your code base.</p>
<h4>Installing Growl</h4>

<p><a href="http://growl.info/downloads.php">Download Growl</a> and install it.  But <strong>don't eject</strong> the Disc Image yet.  We have to install the <code>growlnotify</code> command as well.  This has to be done via the command line, so pull up your Terminal again.</p>
<p>We need to find out where Growl has been mounted to.<br />
<pre class="block_terminal">mount | grep -i growl</pre></p>
<p><strong>Possible Result:</strong><br />
<pre class="block_terminal">/dev/disk2s2 on /Volumes/Growl 1.1.2 (local, nodev, nosuid, read-only, mounted by aizat)</pre></p>
<p>From here you can see it has been mounted on <code>/Volumes/Growl 1.1.2</code>.  Now go back to your Terminal, and we'll install <code>growlnotify</code>.</p>
<pre class="brush: plain; gutter: false;">
cd &quot;/Volumes/Growl 1.1.2/&quot;
cd Extras/growlnotify
sudo ./install.sh
</pre>
<p>By default <code>growlnotify</code> is installed into <code>/usr/local/bin</code>, your applications may  not be able to see that this exists. So let's find out.</p>
<p><strong>Execute:</strong><br />
<pre class="block_terminal">which growlnotify</pre></p>
<p><strong>Desired Result:</strong><br />
<pre class="block_terminal">/usr/local/bin/growlnotify</pre></p>
<p><strong>Possible Result:</strong><br />
<pre class="block_terminal">no growlnotify in /opt/local/bin /opt/local/sbin /usr/local/bin /bin /sbin /usr/bin /usr/sbin</pre></p>
<p>We want the desired result, so what do you do if you don't get it?</p>
<pre class="brush: plain; gutter: false;">echo &quot;export PATH=/usr/local/bin:$PATH&quot; &amp;gt;&amp;gt; ~/.bashrc</pre>
<p>Now <code>growlnotify</code> is accessible by all new Terminal sessions.</p>
<p>Let's give it a shot, and test out Growl!</p>
<pre class="brush: plain; gutter: false;">growlnotify -m &quot;Hey &lt;a href=&quot;http://en.wikipedia.org/wiki/Tony_the_Tiger&quot;&gt;Tony&lt;/a&gt;, isn't this just grrrrrrreat?</pre>
<h4>Integrating Growl with autotest</h4>

<p>We need to create a <code>.autotest</code> (yes with the period) file in your home directory.</p>
<pre class="brush: plain; gutter: false;">
touch ~/.autotest
open ~/.autotest
</pre>
<p>Now stuff this in there!</p>
<pre class="brush: ruby;">
module Autotest::Growl

  def self.growl title, msg, img, pri=0, sticky=&quot;&quot;
    system &quot;growlnotify -n autotest --image #{img.inspect} -p #{pri} -m #{msg.inspect} #{title} #{sticky}&quot;
  end

  Autotest.add_hook :ran_command do |at|
    results = [at.results].flatten.join(&quot;\n&quot;)
    output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+not implemented)?/)
    if output
      if $~[2].to_i &gt; 0
        growl &quot;Test Results&quot;, &quot;#{output}&quot;, File.join(ENV['HOME'], %w[Library Application\ Support autotest rails_fail.png]), 2
      else
        growl &quot;Test Results&quot;, &quot;#{output}&quot;, File.join(ENV['HOME'], %w[Library Application\ Support autotest rails_ok.png])
      end
    end
  end

end
</pre>
<p class="block_important"><strong>Note:</strong> <a href="http://wincent.com/knowledge-base/Setting_up_autotest_to_use_Growl">Adapted from Wincent Knowledge Base</a>. I also took the personal liability to move files to the ~/Library/Application Support/ directory as I thought it would be more appropriate.  Your choice, just change as desired. </p>
<p>Now for the final touch, the elusive images!</p>
<pre class="brush: plain; gutter: false;">
mkdir -p ~/Library/Application\ Support/autotest
cd ~/Library/Application\ Support/autotest
curl -O http://blog.internautdesign.com/files/rails_fail.png
curl -O http://blog.internautdesign.com/files/rails_ok.png
</pre>
<p class="block_important"><strong>Note:</strong> If you want, you can even change the images to whatever you want yourself, just change lines 12 and 14 to point to the image location. </p>
<h4>autotest-ing</h4>

<p>Now go to the root directory of your Rails application, and simply execute:</p>
<pre class="brush: plain; gutter: false;">autotest</pre>
<p>and you should soon be notified of the results of your test.</p>
<p class="block_important"><strong>Note:</strong> You can further customize Growl in the System Preferences! </p>
<h3>Audio Feedback</h3>

<p>Visual feedback is cool, but it would be even more awesome if it had audio feedback to accompany it.</p>
<p class="block_important"><strong>Note:</strong> This method is cross platform. </p>
<p>This was first described on <a href="http://fozworks.com/2007/7/28/autotest-sound-effects">FozWorks (read on how to Install)</a></p>
<p>As I aggregated my <code>autotest</code> images into the <code>~/Library/Application Support/autotest</code> directory, I thought I'd dump the sound files in there as well.  Just pay attention when you have to modify your <code>~/.autotest</code> to accommodate the different path.</p>
<p>The only disappointment with the default sounds they provide is that, they are a little bit soft, and is often drowned out by my music player.  But no worries, you can decide to use your own effects, or if your like me, increase the gain with <a href="http://audacity.sourceforge.net/">Audacity</a>.</p>
<p>In the mean time, anyone have some interesting replacement sound effects?</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.aizatto.com/2007/11/19/autotest-ing-your-rails-plugin/" title="autotest-ing your Rails Plugin (November 19, 2007)">autotest-ing your Rails Plugin</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2007/11/28/taming-the-autotest-beast-with-fsevents/" title="Taming the autotest Beast with FSEvents (November 28, 2007)">Taming the autotest Beast with FSEvents</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2007/05/11/using-rubygems-package-in-ubuntu-feisty-fawn-apt-get-repository/" title="Using RubyGems package in Ubuntu Feisty Fawn apt-get Repository (May 11, 2007)">Using RubyGems package in Ubuntu Feisty Fawn apt-get Repository</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2005/07/23/post-operating-system-trauma/" title="Post-Operating System Trauma (July 23, 2005)">Post-Operating System Trauma</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2007/05/23/why-i-support-free-culture/" title="Why I Support Free Culture (May 23, 2007)">Why I Support Free Culture</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.aizatto.com/2007/11/19/autotest-ting-your-rails-application-with-visual-and-audio-feedback-using-growl-and-mpg321/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using RubyGems package in Ubuntu Feisty Fawn apt-get Repository</title>
		<link>http://blog.aizatto.com/2007/05/11/using-rubygems-package-in-ubuntu-feisty-fawn-apt-get-repository/</link>
		<comments>http://blog.aizatto.com/2007/05/11/using-rubygems-package-in-ubuntu-feisty-fawn-apt-get-repository/#comments</comments>
		<pubDate>Thu, 10 May 2007 16:01:25 +0000</pubDate>
		<dc:creator>aizatto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[RubyGems]]></category>
		<category><![CDATA[Ubuntu 7.04 Feisty Fawn]]></category>

		<guid isPermaLink="false">http://rails.aizatto.com/2007/05/11/using-rubygems-package-in-ubuntu-feisty-fawn-apt-get-repository/</guid>
		<description><![CDATA[After receiving a comment on my post about installing Rails on Ubuntu Feisty Fawn via RubyGems, I found, to my surprise, there exists a rubygems package in the Ubuntu Feisty Fawn universe repository. Though it is a bit outdated at 0.9.0, while the latest is 0.9.2. So the commenter ran into a problem trying to [...]]]></description>
			<content:encoded><![CDATA[<p>After receiving a <a href="http://rails.aizatto.com/2007/05/02/installing-ruby-on-rails-on-ubuntu-feisty-fawn-via-rubygems/#comment-11">comment</a> on my post about <a href="http://rails.aizatto.com/2007/05/02/installing-ruby-on-rails-on-ubuntu-feisty-fawn-via-rubygems/">installing Rails on Ubuntu Feisty Fawn via RubyGems</a>, I found, to my surprise, there exists a <code>rubygems</code> package in the Ubuntu Feisty Fawn universe repository.  Though it is a bit outdated at <code>0.9.0</code>, while the latest is <code>0.9.2</code>.</p>
<p>So the commenter ran into a <strong>problem trying to use the repository installed <code>rubygems</code></strong> and when executing in the terminal <code>rails</code> [image16x16:terminal], they would get a <strong>command not found</strong> error.</p>
<p>In actual fact, the <code>rails</code> program does exist but in another path ( <code>/var/lib/gems/1.8/bin</code> [image16x16:file] ).</p>
<p>There are two solutions to this.  If you want to use the rubygems package from the repository, go with solution 1.  Personally, I would go with solution 2.</p>
<p><i>Select your poison</i>.</p>
<h3>Solution 1: Modify your PATH environment variable</h3>
<p>Open up <code>~/.bashrc</code> [image16x16:file] (This is in your home directory).  <strong>Append</strong> the following:<br />
[block:file]
<pre><code>export PATH=$PATH:/var/lib/gems/1.8/bin</code></pre>
<p>[/block]</p>
<p>Now either source your .bashrc (<code>source ~/.bashrc</code> [image16x16:terminal]) or restart your terminal.  But it should work fine after this.</p>
<h3>Solution 2: Remove the rubygems package and install via source</h3>
<p>[block:terminal]
<pre><code>sudo apt-get remove rubygems</code></pre>
<p>[/block]</p>
<p>Then continue with my guide on <a href="http://rails.aizatto.com/2007/05/02/installing-ruby-on-rails-on-ubuntu-feisty-fawn-via-rubygems/">installing Rails on Ubuntu Feisty Fawn via RubyGems</a>.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.aizatto.com/2007/05/02/installing-ruby-on-rails-on-ubuntu-feisty-fawn-via-rubygems/" title="Installing Ruby on Rails on Ubuntu Feisty Fawn via RubyGems (May 2, 2007)">Installing Ruby on Rails on Ubuntu Feisty Fawn via RubyGems</a> (8)</li>
	<li><a href="http://blog.aizatto.com/2007/11/19/autotest-ting-your-rails-application-with-visual-and-audio-feedback-using-growl-and-mpg321/" title="autotest-ting your Rails Application with Visual and Audio Feedback using Growl and mpg321 (November 19, 2007)">autotest-ting your Rails Application with Visual and Audio Feedback using Growl and mpg321</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2007/05/02/setting-up-ruby-on-rails-database-connection-using-sqlite-version-2-and-3-on-ubuntu-feisty-fawn/" title="Setting up Ruby on Rails Database Connection using SQLite (version 2 and 3) on Ubuntu Feisty Fawn (May 2, 2007)">Setting up Ruby on Rails Database Connection using SQLite (version 2 and 3) on Ubuntu Feisty Fawn</a> (2)</li>
	<li><a href="http://blog.aizatto.com/2007/05/15/setting-up-ruby-on-rails-database-connection-using-mysql-on-ubuntu-feisty-fawn/" title="Setting up Ruby on Rails Database Connection using MySQL on Ubuntu Feisty Fawn (May 15, 2007)">Setting up Ruby on Rails Database Connection using MySQL on Ubuntu Feisty Fawn</a> (6)</li>
	<li><a href="http://blog.aizatto.com/2009/12/07/ruby-on-rails-finite-state-machine-plugin-workflow/" title="Ruby on Rails Finite State Machine Plugin: Workflow (December 7, 2009)">Ruby on Rails Finite State Machine Plugin: Workflow</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.aizatto.com/2007/05/11/using-rubygems-package-in-ubuntu-feisty-fawn-apt-get-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ruby on Rails on Ubuntu Feisty Fawn via RubyGems</title>
		<link>http://blog.aizatto.com/2007/05/02/installing-ruby-on-rails-on-ubuntu-feisty-fawn-via-rubygems/</link>
		<comments>http://blog.aizatto.com/2007/05/02/installing-ruby-on-rails-on-ubuntu-feisty-fawn-via-rubygems/#comments</comments>
		<pubDate>Tue, 01 May 2007 16:16:32 +0000</pubDate>
		<dc:creator>aizatto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[RubyGems]]></category>
		<category><![CDATA[Ubuntu 7.04 Feisty Fawn]]></category>

		<guid isPermaLink="false">http://rails.aizatto.com/2007/05/02/installing-ruby-on-rails-with-rubygems-on-ubuntu-fiesty-fawn/</guid>
		<description><![CDATA[This is a quick down and dirty guide to setting up Ruby on Rails in Ubuntu Feisty Fawn. You may notice this is installed into /tmp, I do this so because its universal on all Ubuntu and Linux distributions. Install Ruby Install RubyGems via source Install Ruby on Rails using RubyGems Test Rails installation Enter [...]]]></description>
			<content:encoded><![CDATA[<p class="block_important"><strong>Note:</strong> </p>
<ul>
<li><a href="http://rails.aizatto.com/2007/04/26/why-you-should-install-ruby-on-rails-using-rubygems/">I recommend installing Ruby on Rails via RubyGems</a></li>
<li>As long as you have Ruby installed, you can install Ruby on Rails, just skip the step about installing Ruby.</li>
</ul>
<p> </p>
<h3>Plan of attack:</h3>

<p>This is a <strong>quick down and dirty guide</strong> to setting up Ruby on Rails in Ubuntu Feisty Fawn.  You may notice this is installed into <code>/tmp</code>,  I do this so because its universal on all Ubuntu and Linux distributions.</p>
<ul>
<li>Install Ruby</li>
<li>Install RubyGems via source</li>
<li>Install Ruby on Rails using RubyGems</li>
<li>Test Rails installation</li>
</ul>
<h3>Install Ruby</h3>

<p>Enter into the Terminal:</p>
<pre class="brush: plain;">sudo apt-get install ruby ri irb</pre>
<h3>Install RubyGems via source</h3>

<p class="block_important"><strong>Note:</strong> <a href="http://rubyforge.org/frs/?group_id=126">Latest RubyGems</a> (v0.9.2) as of 25th April 2007 </p>
<p>Enter into the Terminal:</p>
<pre class="brush: plain;">
cd /tmp
wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz
tar -zxvf rubygems-0.9.2.tgz
cd rubygems-0.9.2
sudo ruby setup.rb
</pre>
<h3>Install Ruby on Rails using RubyGems</h3>

<p>Enter into the Terminal:</p>
<pre class="brush: plain;">sudo gem install -y rails</pre>
<p class="block_important"><strong>Note:</strong> If it fails,  try executing <code>sudo gem update</code> <img src="http://blog.aizatto.com/wp-content/plugins/aizatto_blocks/images/" alt="" title="" /> and then execute the command above again. </p>
<h3>Test Rails installation</h3>

<p>Enter into the Terminal:</p>
<pre class="brush: plain;">
rails /tmp/railstest
cd /tmp/railstest
./script/server
</pre>
<p>Open up Firefox and go to <code><a href="http://localhost:3000">http://localhost:3000</a></code>, a page should show up indicating a successful installation. Your basically good to go with the minor exception of a database connection.</p>
<h3>After...</h3>

<p>Generally you'd want some sort of database connection, with the three standards choices being.</p>
<ul>
<li><a href="http://rails.aizatto.com/2007/05/02/setting-up-ruby-on-rails-database-connection-using-sqlite-version-2-and-3-on-ubuntu-fiesty-fawn/">SQLite</a>:<br />
If you just want to experiment with Ruby on Rails, I'd recommend using SQLite.</li>
<li><a href="http://rails.aizatto.com/2007/05/15/setting-up-ruby-on-rails-database-connection-using-mysql-on-ubuntu-feisty-fawn/">MySQL</a></li>
<li>PostgreSQL</li>
</ul>
<p>Stay tuned!</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://blog.aizatto.com/2007/05/11/using-rubygems-package-in-ubuntu-feisty-fawn-apt-get-repository/" title="Using RubyGems package in Ubuntu Feisty Fawn apt-get Repository (May 11, 2007)">Using RubyGems package in Ubuntu Feisty Fawn apt-get Repository</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2007/05/02/setting-up-ruby-on-rails-database-connection-using-sqlite-version-2-and-3-on-ubuntu-feisty-fawn/" title="Setting up Ruby on Rails Database Connection using SQLite (version 2 and 3) on Ubuntu Feisty Fawn (May 2, 2007)">Setting up Ruby on Rails Database Connection using SQLite (version 2 and 3) on Ubuntu Feisty Fawn</a> (2)</li>
	<li><a href="http://blog.aizatto.com/2007/05/15/setting-up-ruby-on-rails-database-connection-using-mysql-on-ubuntu-feisty-fawn/" title="Setting up Ruby on Rails Database Connection using MySQL on Ubuntu Feisty Fawn (May 15, 2007)">Setting up Ruby on Rails Database Connection using MySQL on Ubuntu Feisty Fawn</a> (6)</li>
	<li><a href="http://blog.aizatto.com/2009/12/07/ruby-on-rails-finite-state-machine-plugin-workflow/" title="Ruby on Rails Finite State Machine Plugin: Workflow (December 7, 2009)">Ruby on Rails Finite State Machine Plugin: Workflow</a> (0)</li>
	<li><a href="http://blog.aizatto.com/2007/05/20/deploying-ruby-on-rails-on-ubuntu-feisty-fawn-via-mongrel-cluster-and-apache/" title="Deploying Ruby on Rails on Ubuntu Feisty Fawn via Mongrel Cluster and Apache (May 20, 2007)">Deploying Ruby on Rails on Ubuntu Feisty Fawn via Mongrel Cluster and Apache</a> (19)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.aizatto.com/2007/05/02/installing-ruby-on-rails-on-ubuntu-feisty-fawn-via-rubygems/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
