<?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>iphone and gis development notes &#187; ruby on rails</title>
	<atom:link href="http:///wordpress/tag/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>/wordpress</link>
	<description>By Rupert</description>
	<lastBuildDate>Mon, 26 Jul 2010 05:06:32 +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>Rails Note #14: QuickStart Tutorial</title>
		<link>/wordpress/2010/02/ruby-on-rails-quickstart-tutorial/</link>
		<comments>/wordpress/2010/02/ruby-on-rails-quickstart-tutorial/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 05:39:31 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=707</guid>
		<description><![CDATA[If you haven&#8217;t installed ruby, follow this post Part 1: Installation and Configuration (Rails and Passenger) 1. Upgrade existing ruby gems sudo gem list sudo gem update --system UPDATE: Took me 4 hours figuring this out. There was a problem when i run script/console that it will say the &#8220;gem&#8221; detected was 1.0.1 although the]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t installed ruby, follow this <a href="/wordpress/2008/11/getting-my-feet-wet-in-ruby-on-rails/">post</a></p>
<p><strong>Part 1: Installation and Configuration (Rails and Passenger)</strong></p>
<p>1. Upgrade existing ruby gems</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem list
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem update <span style="color: #660033;">--system</span></pre></div></div>

<p>UPDATE: Took me 4 hours figuring this out. There was a problem when i run script/console that it will say the &#8220;gem&#8221; detected was 1.0.1 although the current gem version is 1.3.5 after gem update &#8211;system. Google didn&#8217;t helped out. But I was able to nail down the problem from this post:</p>
<p><a href="https://wincent.com/wiki/Upgrading_to_RubyGems_1.0.1_on_Mac_OS_X_10.5.1">https://wincent.com/wiki/Upgrading_to_RubyGems_1.0.1_on_Mac_OS_X_10.5.1</a><br />
In the post above, notice that rubygems 1.0.1 was installed in /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin. I guess this gem was being referenced first before the actual /usr/local/bin/gem. So I deleted this directory /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr.</p>
<p>Possible sources of gem installations:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>.gem<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems
<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Ruby<span style="color: #000000; font-weight: bold;">/</span>Gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rupert:<span style="color: #000000;">1.8</span> rupert$ gem <span style="color: #c20cb9; font-weight: bold;">env</span>
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.5
  - RUBY VERSION: 1.8.6 <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2008</span>-08-08 patchlevel <span style="color: #000000;">286</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>i686-darwin9.5.0<span style="color: #7a0874; font-weight: bold;">&#93;</span>
  - INSTALLATION DIRECTORY: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span>
  - RUBY EXECUTABLE: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby
  - EXECUTABLE DIRECTORY: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-<span style="color: #000000;">9</span>
  - GEM PATHS:
     - <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span>
     - <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>.gem<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span>
  - GEM CONFIGURATION:
     - :update_sources =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
     - :verbose =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
     - :benchmark =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">false</span>
     - :backtrace =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">false</span>
     - :bulk_threshold =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000;">1000</span>
  - REMOTE SOURCES:
     - http:<span style="color: #000000; font-weight: bold;">//</span>gems.rubyforge.org<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>2. Install rails. Download from ruby-forge. Link?</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-V</span> rails-2.3.3.gem
gem <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-V</span> mysql</pre></div></div>

<p>3. Install and configure passenger for Apache2</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-V</span> passenger
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>.gem<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.5<span style="color: #000000; font-weight: bold;">/</span>bin
passenger-install-apache2-module</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">469 LoadModule passenger_module /Users/rupert/.gem/ruby/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
470 PassengerRoot /Users/rupert/.gem/ruby/1.8/gems/passenger-2.2.5
471 PassengerRuby /usr/local/bin/ruby
472 
473 &lt;VirtualHost *:80&gt;
474   RailsBaseURI /rails/travelsiteph
475 &lt;/VirtualHost&gt;</pre></div></div>

<p>4. Create a sample rails project (&#8220;travelsiteph&#8221;) in your project directory (&#8220;/Users/rupert/projects/rails&#8221;).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>rails
$ rails travelisteph
      create  
      create  app<span style="color: #000000; font-weight: bold;">/</span>controllers
      create  app<span style="color: #000000; font-weight: bold;">/</span>helpers
      create  app<span style="color: #000000; font-weight: bold;">/</span>models
      create  app<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/</span>layouts
      create  config<span style="color: #000000; font-weight: bold;">/</span>environments
	.....
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-la</span> travelsiteph
drwxr-xr-x  <span style="color: #000000;">15</span> rupert  admin    <span style="color: #000000;">510</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> .
drwxr-xr-x   <span style="color: #000000;">5</span> rupert  admin    <span style="color: #000000;">170</span> <span style="color: #000000;">30</span> Sep <span style="color: #000000;">16</span>:<span style="color: #000000;">31</span> ..
<span style="color: #660033;">-rw-r--r--</span>   <span style="color: #000000;">1</span> rupert  admin  <span style="color: #000000;">10011</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> README
<span style="color: #660033;">-rw-r--r--</span>   <span style="color: #000000;">1</span> rupert  admin    <span style="color: #000000;">307</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> Rakefile
drwxr-xr-x   <span style="color: #000000;">6</span> rupert  admin    <span style="color: #000000;">204</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> app
drwxr-xr-x   <span style="color: #000000;">9</span> rupert  admin    <span style="color: #000000;">306</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> config
drwxr-xr-x   <span style="color: #000000;">4</span> rupert  admin    <span style="color: #000000;">136</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">18</span> db
drwxr-xr-x   <span style="color: #000000;">3</span> rupert  admin    <span style="color: #000000;">102</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> doc
drwxr-xr-x   <span style="color: #000000;">3</span> rupert  admin    <span style="color: #000000;">102</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> lib
drwxr-xr-x   <span style="color: #000000;">6</span> rupert  admin    <span style="color: #000000;">204</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> log
drwxr-xr-x  <span style="color: #000000;">11</span> rupert  admin    <span style="color: #000000;">374</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> public
drwxr-xr-x  <span style="color: #000000;">11</span> rupert  admin    <span style="color: #000000;">374</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> script
drwxr-xr-x   <span style="color: #000000;">8</span> rupert  admin    <span style="color: #000000;">272</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">55</span> <span style="color: #7a0874; font-weight: bold;">test</span>
drwxr-xr-x   <span style="color: #000000;">6</span> rupert  admin    <span style="color: #000000;">204</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">22</span>:07 tmp
drwxr-xr-x   <span style="color: #000000;">3</span> rupert  admin    <span style="color: #000000;">102</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">21</span>:<span style="color: #000000;">14</span> vendor</pre></div></div>

<p>I have /wwwroot as my document WebRoot. Its running cf, php and mapserv (cgi-bin). Since I want to mix it with rails development, I&#8217;ll just make a rails subdirectory. Inside the rails subdirectory, I can create symbolic links to my rails applications located in my projects directory. This way, rails configuration is not exposed from Apache.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>wwwroot
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> rails
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>rails<span style="color: #000000; font-weight: bold;">/</span>travelsiteph<span style="color: #000000; font-weight: bold;">/</span>public travelsiteph
&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-la</span>
total <span style="color: #000000;">8</span>
drwxr-xr-x   <span style="color: #000000;">3</span> rupert  admin   <span style="color: #000000;">102</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">14</span>:09 .
drwxrwxr-x  <span style="color: #000000;">60</span> root    admin  <span style="color: #000000;">2040</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">14</span>:08 ..
lrwxr-xr-x   <span style="color: #000000;">1</span> rupert  admin    <span style="color: #000000;">42</span>  <span style="color: #000000;">2</span> Sep <span style="color: #000000;">14</span>:09 travelsiteph -<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>rails<span style="color: #000000; font-weight: bold;">/</span>travelsiteph<span style="color: #000000; font-weight: bold;">/</span>public</pre></div></div>

<p>5. Restart Apache to take the new configuration</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>StartupItems<span style="color: #000000; font-weight: bold;">/</span>Apache2<span style="color: #000000; font-weight: bold;">/</span>Apache2 restart</pre></div></div>

<p>6. Open http://127.0.0.1/rails/travelsiteph/</p>
<p><em>But for development purposes, it is better to use http://127.0.0.1:3000/ to see immediately any changes in code.</em> </p>
<p><img src="/wordpress/wp-content/uploads/2009/09/rails.png" alt="rails.png" border="0" width="150" height="108" /></p>
<p><strong>Part 2: Rails Development</strong><br />
MySQL Prerequisites:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">ALL</span> PRIVILEGES <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #66cc66;">*.*</span> <span style="color: #993333; font-weight: bold;">TO</span> rupert@<span style="color: #ff0000;">'%'</span> <span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">'*************'</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">OPTION</span>;
$ mysql <span style="color: #66cc66;">-</span>u rupert <span style="color: #66cc66;">-</span>p</pre></div></div>

<p>1. Create three databases:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> travelsiteph_development;
Query OK<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span> row affected <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span>
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> travelsiteph_test;
Query OK<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span> row affected <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span>
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> travelsiteph_deployment;
Query OK<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span> row affected <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>2. Launch Textmate</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>rails<span style="color: #000000; font-weight: bold;">/</span>travelsiteph
mate .</pre></div></div>

<p>3. Edit database.yml</p>

<div class="wp_syntax"><div class="code"><pre class="yml" style="font-family:monospace;">development:
  adapter: mysql
  database: travelsiteph_development
  username: root
  password: xxxxxxx
  host: localhost
&nbsp;
test:
  adapter: mysql
  database: travelsiteph_test
  username: root
  password: xxxxxxx
  host: localhost
&nbsp;
production:
  adapter: mysql
  database: travelsiteph_deployment
  username: root
  password: xxxxxxx
  host: localhost</pre></div></div>

<p>4. Generate a Poi model. <em>The model should be capitalized and singular.</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ruby script<span style="color: #000000; font-weight: bold;">/</span>generate model Poi
      exists  app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>
      exists  test<span style="color: #000000; font-weight: bold;">/</span>unit<span style="color: #000000; font-weight: bold;">/</span>
      exists  test<span style="color: #000000; font-weight: bold;">/</span>fixtures<span style="color: #000000; font-weight: bold;">/</span>
      create  app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>poi.rb
      create  test<span style="color: #000000; font-weight: bold;">/</span>unit<span style="color: #000000; font-weight: bold;">/</span>poi_test.rb
      create  test<span style="color: #000000; font-weight: bold;">/</span>fixtures<span style="color: #000000; font-weight: bold;">/</span>pois.yml
      create  db<span style="color: #000000; font-weight: bold;">/</span>migrate
      create  db<span style="color: #000000; font-weight: bold;">/</span>migrate<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">20090902111538</span>_create_pois.rb</pre></div></div>

<p>5. Now let&#8217;s create the database table for Poi using migrations.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Poi <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    create_table <span style="color:#ff3333; font-weight:bold;">:pois</span>, <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:poi_id</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:full_address</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:location</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:get_there</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:short_description</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:full_description</span>, <span style="color:#ff3333; font-weight:bold;">:text</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:other_info</span>, <span style="color:#ff3333; font-weight:bold;">:text</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:tel_no</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:fax_no</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:mobile_no</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:email</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:website</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:other_contact_details</span>, <span style="color:#ff3333; font-weight:bold;">:text</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:longitude</span>, <span style="color:#ff3333; font-weight:bold;">:decimal</span>, <span style="color:#ff3333; font-weight:bold;">:precision</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span>, <span style="color:#ff3333; font-weight:bold;">:scale</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">7</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:latitude</span>, <span style="color:#ff3333; font-weight:bold;">:decimal</span>, <span style="color:#ff3333; font-weight:bold;">:precision</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span>, <span style="color:#ff3333; font-weight:bold;">:scale</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">7</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:created_at</span>, <span style="color:#ff3333; font-weight:bold;">:timestamp</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:updated_at</span>, <span style="color:#ff3333; font-weight:bold;">:timestamp</span>
      t.<span style="color:#9900CC;">timestamps</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    drop_table <span style="color:#ff3333; font-weight:bold;">:pois</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ rake db:migrate
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>rails<span style="color: #000000; font-weight: bold;">/</span>travelsiteph<span style="color: #7a0874; font-weight: bold;">&#41;</span>
==  CreatePois: migrating =========================================
<span style="color: #660033;">--</span> create_table<span style="color: #7a0874; font-weight: bold;">&#40;</span>:point_of_interests, <span style="color: #7a0874; font-weight: bold;">&#123;</span>:<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">id</span></span>=<span style="color: #000000; font-weight: bold;">&gt;</span>:poi_id<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
   -<span style="color: #000000; font-weight: bold;">&gt;</span> 0.0353s
==  CreatePois: migrated <span style="color: #7a0874; font-weight: bold;">&#40;</span>0.0362s<span style="color: #7a0874; font-weight: bold;">&#41;</span> ================================</pre></div></div>

<p>6. Generate a Poi controller.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ script<span style="color: #000000; font-weight: bold;">/</span>generate controller Poi
      exists  app<span style="color: #000000; font-weight: bold;">/</span>controllers<span style="color: #000000; font-weight: bold;">/</span>
      exists  app<span style="color: #000000; font-weight: bold;">/</span>helpers<span style="color: #000000; font-weight: bold;">/</span>
      create  app<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/</span>poi
      create  test<span style="color: #000000; font-weight: bold;">/</span>functional<span style="color: #000000; font-weight: bold;">/</span>
      create  test<span style="color: #000000; font-weight: bold;">/</span>unit<span style="color: #000000; font-weight: bold;">/</span>helpers<span style="color: #000000; font-weight: bold;">/</span>
      create  app<span style="color: #000000; font-weight: bold;">/</span>controllers<span style="color: #000000; font-weight: bold;">/</span>poi_controller.rb
      create  test<span style="color: #000000; font-weight: bold;">/</span>functional<span style="color: #000000; font-weight: bold;">/</span>poi_controller_test.rb
      create  app<span style="color: #000000; font-weight: bold;">/</span>helpers<span style="color: #000000; font-weight: bold;">/</span>poi_helper.rb
      create  test<span style="color: #000000; font-weight: bold;">/</span>unit<span style="color: #000000; font-weight: bold;">/</span>helpers<span style="color: #000000; font-weight: bold;">/</span>poi_helper_test.rb</pre></div></div>

<p>7. Add a <em>list</em> function to Poi Controller</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> PoiController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
  <span style="color:#9966CC; font-weight:bold;">def</span> list
    <span style="color:#0066ff; font-weight:bold;">@pois</span> = Poi.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>8. Lets test. Open a browser and point to http://127.0.0.1:3000/travelsiteph/poi/list</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$ruby</span> script<span style="color: #000000; font-weight: bold;">/</span>server</pre></div></div>

<p>9. Now create the view <em>list.rhtml</em> in <em>views/poi/</em></p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@pois</span>.<span style="color:#9900CC;">blank</span>? <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
	&lt;p&gt;There are currently no pois in the system. &lt;/p&gt;
&nbsp;
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">else</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
	&lt;p&gt;These are the pois in the system: &lt;/p&gt;
&nbsp;
	&lt;ul&gt;
		<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#0066ff; font-weight:bold;">@pois</span>.<span style="color:#5A0A0A; font-weight:bold;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>poi<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
			&lt;li&gt;<span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#5A0A0A; font-weight:bold;">link_to</span> poi.<span style="color:#9900CC;">name</span>, <span style="color:#006600; font-weight:bold;">&#123;</span>:action <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'show'</span>, <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> poi.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">-%&gt;</span>&lt;/li&gt;
		<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
	&lt;/ul&gt;
&nbsp;
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p><strong>Part 3: Deploying</strong><br />
1. set RAILS_ENV to production</p>
<pre>export RAILS_ENV=production</pre>
<p>2. Make sure to populate the database in production mode, run rake db:migrate</p>
<p>3. Capistrano</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">set <span style="color:#ff3333; font-weight:bold;">:port</span>, <span style="color:#006666;">2210</span>
set <span style="color:#ff3333; font-weight:bold;">:application</span>, <span style="color:#996600;">&quot;halalan2010&quot;</span>
<span style="color:#008000; font-style:italic;">#set :repository,  &quot;svn+ssh://2rmobile.com/data/repos/web/rails/halalan2010/&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:repository</span>,  <span style="color:#996600;">&quot;http://2rmobile.com/repos/web/rails/halalan2010/&quot;</span>
&nbsp;
set <span style="color:#ff3333; font-weight:bold;">:scm</span>, <span style="color:#ff3333; font-weight:bold;">:subversion</span>
set <span style="color:#ff3333; font-weight:bold;">:scm_username</span>, <span style="color:#996600;">'rupert'</span>
set <span style="color:#ff3333; font-weight:bold;">:scm_password</span>, <span style="color:#CC0066; font-weight:bold;">proc</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#6666ff; font-weight:bold;">Capistrano::CLI</span>.<span style="color:#9900CC;">password_prompt</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'SVN pass:'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#008000; font-style:italic;"># Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`</span>
&nbsp;
role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;2rmobile.com&quot;</span> <span style="color:#008000; font-style:italic;"># IP Your HTTP server, Apache/etc</span>
role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;2rmobile.com&quot;</span> <span style="color:#008000; font-style:italic;"># This may be the same as your `Web` server</span>
role <span style="color:#ff3333; font-weight:bold;">:db</span>,  <span style="color:#996600;">&quot;2rmobile.com&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#008000; font-style:italic;"># This is where Rails migrations will run</span>
<span style="color:#008000; font-style:italic;">#role :db,  &quot;your slave db-server here&quot;</span>
&nbsp;
set <span style="color:#ff3333; font-weight:bold;">:user</span>,  <span style="color:#996600;">&quot;rupert&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:runner</span>, <span style="color:#996600;">&quot;rupert&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:deploy_to</span>, <span style="color:#996600;">&quot;/opt/rails/#{application}&quot;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># If you are using Passenger mod_rails uncomment this:</span>
<span style="color:#008000; font-style:italic;"># if you're still using the script/reapear helper you will need</span>
<span style="color:#008000; font-style:italic;"># these http://github.com/rails/irs_process_scripts</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:deploy</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  task <span style="color:#ff3333; font-weight:bold;">:start</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    run <span style="color:#996600;">&quot;/etc/init.d/apache2 start&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  task <span style="color:#ff3333; font-weight:bold;">:stop</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    run <span style="color:#996600;">&quot;/etc/init.d/apache2 stop&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  task <span style="color:#ff3333; font-weight:bold;">:restart</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:except</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:no_release</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
     run <span style="color:#996600;">&quot;#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  task <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    run <span style="color:#996600;">&quot;export RAILS_ENV=production&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:db</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  task <span style="color:#ff3333; font-weight:bold;">:seed</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    run <span style="color:#996600;">&quot;cd #{deploy_to}/current &amp;&amp; RAILS_ENV=production rake db:seed&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  task <span style="color:#ff3333; font-weight:bold;">:populate</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    run <span style="color:#996600;">&quot;cd #{deploy_to}/current &amp;&amp; RAILS_ENV=production rake db:populate&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Capistrano commands I normally use:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">#on local
#cap deploy:setup
&nbsp;
#on remote and change owner and permissions of project
sudo chown -Rf rupert:root halalan2010
&nbsp;
#on local
#cap deploy
#cap db:seed
#cap db:populate</pre></div></div>

<p><strong>Part 4: Miscellaneous</strong></p>
<p><strong>1. Get a description or rake commands</strong></p>
<pre>rake -D db</pre>
<p><strong>2. How to populate the database in production mode?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="console" style="font-family:monospace;">rupert:halalan2010 rupert$ export RAILS_ENV=production
rupert:halalan2010 rupert$ rake db:migrate
(in /Users/rupert/projects/rails/halalan2010)
==  CreateDatabase: migrating =================================================
-- create_table(:candidates)
   -&gt; 0.0036s
-- create_table(:voters)
   -&gt; 0.0031s
-- create_table(:votes)
   -&gt; 0.0027s
==  CreateDatabase: migrated (0.0100s) ========================================</pre></div></div>

<p><a href="http://blog.airbladesoftware.com/2009/4/10/avoid-typing-rails_env-all-the-time">http://blog.airbladesoftware.com/2009/4/10/avoid-typing-rails_env-all-the-time</a></p>
<p><strong>3. Uninstall specific gem version</strong></p>
<pre>
gem uninstall activesupport -v 2.2.2
</pre>
<p><strong>4 Add a source to gem</strong></p>
<pre>
rupert:rails rupert$ sudo gem sources -a http://gems.github.com
http://gems.github.com added to sources
</pre>
<p><strong>5. Adding a rails project in svn</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#create a remote dir</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.2rmobile.com<span style="color: #000000; font-weight: bold;">/</span>repos<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>rails<span style="color: #000000; font-weight: bold;">/</span>virginmobilechecker
&nbsp;
<span style="color: #666666; font-style: italic;">#checkout and copy all files</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>rails
<span style="color: #c20cb9; font-weight: bold;">mv</span> virginmobilechecker virginmobilechecker_old
<span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> <span style="color: #ff0000;">&quot;svn+ssh://2rmobile.com/data/repos/web/rails/virginmobilechecker&quot;</span> virginmobilechecker
<span style="color: #c20cb9; font-weight: bold;">mv</span> virginmobilechecker_old<span style="color: #000000; font-weight: bold;">/*</span> virginmobilechecker<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> virginmobilechecker
<span style="color: #c20cb9; font-weight: bold;">svn</span> add <span style="color: #000000; font-weight: bold;">*</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#ignoring log files</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> revert log<span style="color: #000000; font-weight: bold;">/*</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> propset <span style="color: #c20cb9; font-weight: bold;">svn</span>:ignore <span style="color: #ff0000;">&quot;*.log&quot;</span> log
<span style="color: #c20cb9; font-weight: bold;">svn</span> propset <span style="color: #c20cb9; font-weight: bold;">svn</span>:ignore <span style="color: #ff0000;">&quot;*&quot;</span> tmp
<span style="color: #c20cb9; font-weight: bold;">svn</span> propset <span style="color: #c20cb9; font-weight: bold;">svn</span>:ignore <span style="color: #ff0000;">&quot;*&quot;</span> doc
&nbsp;
<span style="color: #666666; font-style: italic;">#commit the files</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;first commit&quot;</span> <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2010/02/ruby-on-rails-quickstart-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #13: RubyonRails + Oracle on Linux (i386 / x64)</title>
		<link>/wordpress/2008/12/rubyonrails-oracle-on-linux-i386-x64/</link>
		<comments>/wordpress/2008/12/rubyonrails-oracle-on-linux-i386-x64/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 03:53:48 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=310</guid>
		<description><![CDATA[In summary, install Oracle Instant Client and try to run sqlplus. If sqlplus connects to the oracle sid then go ahead and install the rails adapters for oracle. What is important to note here, is to install the oracle-instantclient for the architecture of your machine.. I have tested this on Debian Lenny (i386) and CentOS5]]></description>
			<content:encoded><![CDATA[<p>In summary, install Oracle Instant Client and try to run sqlplus. If sqlplus connects to the oracle sid then go ahead and install the rails adapters for oracle. <strong>What is important to note here, is to install the oracle-instantclient for the architecture of your machine.</strong>. I have tested this on Debian Lenny (i386) and CentOS5 (x64)</p>
<p>1. Download from <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/">http://www.oracle.com/technology/software/tech/oci/instantclient/</a></p>
<p>a. oracle-instantclient-basic-10.2.0.4-1.i386<br />
b. oracle-instantclient-devel-10.2.0.4-1.i386<br />
c. oracle-instantclient-sqlplus-10.2.0.4-1.i386</p>
<p>2. Unzip everything to /opt/oracle/instantclient . You should have something like the ff:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>csapp1 instantclient<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ls -la</span>
total <span style="color: #000000;">102704</span>
drwxr-xr-x <span style="color: #000000;">3</span> root root     <span style="color: #000000;">4096</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">54</span> .
drwxr-xr-x <span style="color: #000000;">3</span> root root     <span style="color: #000000;">4096</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">22</span>:03 ..
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root      <span style="color: #000000;">228</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> BASIC_README
<span style="color: #660033;">-r--r--r--</span> <span style="color: #000000;">1</span> root root  <span style="color: #000000;">1609607</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> classes12.jar
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">1</span> root root    <span style="color: #000000;">67542</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> genezi
<span style="color: #660033;">-r--r--r--</span> <span style="color: #000000;">1</span> root root     <span style="color: #000000;">1525</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> glogin.sql
lrwxrwxrwx <span style="color: #000000;">1</span> root root       <span style="color: #000000;">17</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">54</span> libclntsh.so -<span style="color: #000000; font-weight: bold;">&gt;</span> libclntsh.so.10.1
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">21038613</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> libclntsh.so.10.1
<span style="color: #660033;">-r-xr-xr-x</span> <span style="color: #000000;">1</span> root root  <span style="color: #000000;">3796601</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> libnnz10.so
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">1</span> root root  <span style="color: #000000;">1664116</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> libocci.so.10.1
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">72674185</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> libociei.so
<span style="color: #660033;">-r-xr-xr-x</span> <span style="color: #000000;">1</span> root root   <span style="color: #000000;">138033</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> libocijdbc10.so
<span style="color: #660033;">-r-xr-xr-x</span> <span style="color: #000000;">1</span> root root  <span style="color: #000000;">1435561</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> libsqlplusic.so
<span style="color: #660033;">-r-xr-xr-x</span> <span style="color: #000000;">1</span> root root   <span style="color: #000000;">997409</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> libsqlplus.so
<span style="color: #660033;">-r--r--r--</span> <span style="color: #000000;">1</span> root root  <span style="color: #000000;">1555682</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> ojdbc14.jar
drwxr-xr-x <span style="color: #000000;">4</span> root root     <span style="color: #000000;">4096</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> sdk
<span style="color: #660033;">-r-xr-xr-x</span> <span style="color: #000000;">1</span> root root     <span style="color: #000000;">7773</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> sqlplus
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root      <span style="color: #000000;">232</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">52</span> SQLPLUS_README
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root      <span style="color: #000000;">516</span> Dec <span style="color: #000000;">10</span> <span style="color: #000000;">21</span>:<span style="color: #000000;">53</span> tnsnames.ora
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>csapp1 instantclient<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;">#</span></pre></div></div>

<p>3. Make a symbolic link for libclntsh.so.10.1 as shown above.</p>
<p>4. Create the Oracle Environment variables</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ORACLE_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>instantclient
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TNS_ADMIN</span>=<span style="color: #007800;">$ORACLE_HOME</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LD_LIBRARY_PATH</span>=<span style="color: #007800;">$ORACLE_HOME</span>:<span style="color: #007800;">$LD_LIBRARY_PATH</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">DYLD_LIBRARY_PATH</span>=<span style="color: #007800;">$ORACLE_HOME</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #007800;">$ORACLE_HOME</span></pre></div></div>

<p>5. At this point, you should have oracle-instantclient properly installed. You can test by running <strong>sqlplus</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>csapp1 instantclient<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># sqlplus</span>
&nbsp;
SQL<span style="color: #000000; font-weight: bold;">*</span>Plus: Release 10.2.0.4.0 - Production on Thu Dec <span style="color: #000000;">11</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">40</span> <span style="color: #000000;">2008</span>
&nbsp;
Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">1982</span>, <span style="color: #000000;">2007</span>, Oracle.  All Rights Reserved.</pre></div></div>

<p>NOTE: Sometimes you will get a SEGMENTATION FAULT. If so, try to open a new shell with the environment variables loaded and do an <strong>sqlplus</strong> in a directory which is not <em>/opt/oracle/instantclient</em>.</p>
<p>6. Install the oracle adapter for rails</p>
<p>7. gem install ruby-oci8</p>
<p>8. gem install oracle_enhanced-adapter &#8211;source=&#8221;http://gems.rubyonrails.org/&#8221;</p>
<p>activerecord-oracle-adapter (1.0.0.9250)<br />
activerecord-oracle_enhanced-adapter (1.1.8)</p>
<p>NOTE: Try to look for the latest gems, the source above is at the time of this writing so it might change.</p>
<p>9. Test using <strong>irb</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>csapp1 instantclient<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># irb</span>
irb<span style="color: #7a0874; font-weight: bold;">&#40;</span>main<span style="color: #7a0874; font-weight: bold;">&#41;</span>:001:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">&gt;</span> require <span style="color: #ff0000;">'rubygems'</span>
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
irb<span style="color: #7a0874; font-weight: bold;">&#40;</span>main<span style="color: #7a0874; font-weight: bold;">&#41;</span>:002:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">&gt;</span> require <span style="color: #ff0000;">'oci8'</span>
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
irb<span style="color: #7a0874; font-weight: bold;">&#40;</span>main<span style="color: #7a0874; font-weight: bold;">&#41;</span>:003:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/12/rubyonrails-oracle-on-linux-i386-x64/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #12: Oracle on Intel Mac</title>
		<link>/wordpress/2008/12/ruby-and-rails-oracle-on-intel-mac/</link>
		<comments>/wordpress/2008/12/ruby-and-rails-oracle-on-intel-mac/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 10:52:28 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=307</guid>
		<description><![CDATA[1. Read http://www.foliosus.com/2008/05/05/connecting-ruby-on-rails-to-oracle-on-an-intel-mac-in-leopard-take-2/ 2. Install Oracle Instant Client on Mac. a. Instant Client Package &#8211; Basic: All files required to run OCI, OCCI, and JDBC-OCI applications - instantclient-basic-macosx-10.2.0.4.0.zip (34,020,719 bytes) b. *Instant Client Package &#8211; SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client instantclient-sdk-macosx-10.2.0.4.0.zip (603,493 bytes) OR download]]></description>
			<content:encoded><![CDATA[<p>1.  Read <a href="http://www.foliosus.com/2008/05/05/connecting-ruby-on-rails-to-oracle-on-an-intel-mac-in-leopard-take-2/">http://www.foliosus.com/2008/05/05/connecting-ruby-on-rails-to-oracle-on-an-intel-mac-in-leopard-take-2/</a></p>
<p>2. Install <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html">Oracle Instant Client on Mac</a>. </p>
<p>a. Instant Client Package &#8211; Basic: All files required to run OCI, OCCI, and JDBC-OCI applications<br />
- instantclient-basic-macosx-10.2.0.4.0.zip (34,020,719 bytes)</p>
<p>b. *Instant Client Package &#8211; SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client<br />
instantclient-sdk-macosx-10.2.0.4.0.zip (603,493 bytes) </p>
<p>OR download the <a href="/installers/oracle/10.2.0.4.zip">whole bundle (10.2.0.4.zip)</a> with sqlplus installed from my installers.</p>
<p>3. Put this on your sudo vim ~/.bash_profile.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ORACLE_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Oracle<span style="color: #000000; font-weight: bold;">/</span>instantclient<span style="color: #000000; font-weight: bold;">/</span>10.2.0.4
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TNS_ADMIN</span>=<span style="color: #007800;">$ORACLE_HOME</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LD_LIBRARY_PATH</span>=<span style="color: #007800;">$ORACLE_HOME</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">DYLD_LIBRARY_PATH</span>=<span style="color: #007800;">$ORACLE_HOME</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #007800;">$ORACLE_HOME</span></pre></div></div>

<p>4. Make a symbolic link</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Oracle<span style="color: #000000; font-weight: bold;">/</span>instantclient<span style="color: #000000; font-weight: bold;">/</span>10.2.0.4
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> libclntsh.dylib.10.1 libclntsh.dylib</pre></div></div>

<p>5. Go to /Library/Oracle/instantclient/10.2.0.4 and edit tnsnames.ora. Point the Oracle SID to the IP where you installed Oracle.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.155)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )   
  )
&nbsp;
&nbsp;
ORCL_2_11 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.11)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )   
  )</pre></div></div>

<p>6. Install the oracle-adapter for rails</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> activerecord-oracle-adapter <span style="color: #660033;">--source</span> http:<span style="color: #000000; font-weight: bold;">//</span>gems.rubyonrails.org</pre></div></div>

<p>7. In your database.yml file</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">development:
  adapter: oracle
  database: orcl
  username: youzhu_mobile_dev
  password: your_password</pre></div></div>

<p>or browse the contents of a sample rails project <a href="/wordpress/wp-content/uploads/2008/12/youzhumobiletar.gz" title="youzhumobile.tar.gz">youzhumobile.tar.gz</a> </p>
<p>8. If you ever encounter an <strong>encoding problem</strong>, then we need to set the NLS_LANG environment variable before running <em>script/server</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># export NLS_LANG=American_America.UTF8</span>
<span style="color: #666666; font-style: italic;"># script/server</span></pre></div></div>

<p>or I prefer setting it in the environment.rb</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Rails::Initializer</span>.<span style="color:#9900CC;">run</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>config<span style="color:#006600; font-weight:bold;">|</span>
  ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'NLS_LANG'</span><span style="color:#006600; font-weight:bold;">&#93;</span>=<span style="color:#996600;">'American_America.UTF8'</span>
  <span style="color:#008000; font-style:italic;"># Settings in config/environments/* take precedence over those specified here.</span></pre></div></div>

<p>Note: <a href="/wordpress/?p=228">If you don&#8217;t know your database encoding, then read this post.</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/12/ruby-and-rails-oracle-on-intel-mac/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails Note #11: TDD and Loading Development Fixtures for Testing</title>
		<link>/wordpress/2008/11/ruby-on-rails-tdd-and-loading-development-fixtures-for-testing/</link>
		<comments>/wordpress/2008/11/ruby-on-rails-tdd-and-loading-development-fixtures-for-testing/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 14:32:10 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=301</guid>
		<description><![CDATA[Here is a brief outline on how I am doing test driven development personally. 1. Code up tests/functional/foo_controller_test.rb until you know what you expect from the method. Make the test method as self explanatory as much as possible. def test_goto_restaurant_next end 2. Imagine how the URL parameters will be passed to the controller. get :goto,]]></description>
			<content:encoded><![CDATA[<p>Here is a brief outline on how I am doing test driven development <em>personally</em>.</p>
<p>1. Code up tests/functional/foo_controller_test.rb until you know what you expect from the method. Make the test method as self explanatory as much as possible.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> test_goto_restaurant_next
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>2. Imagine how the URL parameters will be passed to the controller.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">get <span style="color:#ff3333; font-weight:bold;">:goto</span>, <span style="color:#996600;">'WHOISD-ABONENT'</span><span style="color:#006600; font-weight:bold;">=&gt;</span> MOBILE_NUMBER, <span style="color:#ff3333; font-weight:bold;">:categ_id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'123'</span>, <span style="color:#ff3333; font-weight:bold;">:node_id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'10'</span>, <span style="color:#ff3333; font-weight:bold;">:page</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'2'</span></pre></div></div>

<p>3. At this point. It gets too exciting to code up the controller itself. Hold on, try to make an assertion on a variable that we will use in the view.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">assert_equal assigns<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;sub_menus&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">length</span>, <span style="color:#006666;">2</span></pre></div></div>

<p>4. Code the controller</p>
<p>5. Code the view</p>
<p>6. Test from the browser.</p>
<p>7. Refactor the testcase and make more assertions.</p>
<p>8. Run the testcase</p>
<p>Now, it could be very hard to execute the tests if you don&#8217;t have the same <strong>development data</strong> inside your <em>testing</em> database. I found a good tip from the Rail&#8217;s Way book, and used ar_fixtures.</p>
<p><cite>For whatever reason, dumping data to fixtures is not a part of core Rails. Considering that Rails gives you a to_yaml method on ActiveRecord models and Hash objects, it wouldn’t be too hard to write your own Rake task. However, it’s not necessary to do so because of a well-proven plugin written by Geoff Grosenbach. It’s called ar_fixtures and you can install it with the following command:<br />
</cite></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">$ script<span style="color:#006600; font-weight:bold;">/</span>plugin install http:<span style="color:#006600; font-weight:bold;">//</span>topfunky.<span style="color:#9900CC;">net</span><span style="color:#006600; font-weight:bold;">/</span>svn<span style="color:#006600; font-weight:bold;">/</span>plugins<span style="color:#006600; font-weight:bold;">/</span>ar_fixtures</pre></div></div>

<p><cite>Once the plugin is installed, dumping a fixture is a simple matter of invoking a new rake task called rake db:fixtures:dump. Unlike the built-in loading rake task, this one takes a MODEL parameter with the name of the ActiveRecord class that you want to dump data for:</cite></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">$ rake db:fixtures:dump MODEL=BillingCode</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/ruby-on-rails-tdd-and-loading-development-fixtures-for-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #10: Generating XML</title>
		<link>/wordpress/2008/11/rubyonrails-generating-xml/</link>
		<comments>/wordpress/2008/11/rubyonrails-generating-xml/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 12:58:46 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=300</guid>
		<description><![CDATA[This post should have made it a looong time ago.. I am currently building an application where all the output formats is in XML. One of the first problems I had was to output the xml. 1. At first try, I could append &#8216;xml&#8217; in the routes as a format parameter. But this takes into]]></description>
			<content:encoded><![CDATA[<p>This post should have made it a looong time ago.. </p>
<p>I am currently building an application where all the output formats is in XML. One of the first problems I had was to output the xml. </p>
<p>1. At first try, I could append &#8216;xml&#8217; in the routes as a format parameter. But this takes into consideration that all our views would be in XML. However, you could have your views to be index.xml.erb or index.rxml, if you are using the <strong>builder templates</strong> plugin.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">ActionController::Routing::Routes</span>.<span style="color:#9900CC;">draw</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>map<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#008000; font-style:italic;">#map.connect '/menu/show.xml', :controller =&gt; 'menu', :action =&gt; 'show', :format =&gt; 'xml'</span>
&nbsp;
  map.<span style="color:#9900CC;">connect</span> <span style="color:#996600;">':controller/:action/:id'</span>, <span style="color:#ff3333; font-weight:bold;">:format</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'xml'</span>
  map.<span style="color:#9900CC;">connect</span> <span style="color:#996600;">':controller/:action/:id.:format'</span>, <span style="color:#ff3333; font-weight:bold;">:format</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'xml'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>2. If my application requires me to output both html and xml, then the above would not be sufficient. In my controller, I have to explicitly say <strong>:layout => false</strong> which means it would not use the <strong>application.html.erb</strong> found in <em>app/views/layouts</em> if we have one.</p>
<p>So far, I made progress using builder templates only but it is enough to suit my needs. Below is a sample controller and view.</p>
<p><strong>app/controller/mobile_controller.rb</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> index
  headers<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Content-Type'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'text/xml; charset=utf-8'</span>
  render <span style="color:#ff3333; font-weight:bold;">:layout</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>app/views/index.rxml</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">xml.<span style="color:#9900CC;">instruct</span>! <span style="color:#ff3333; font-weight:bold;">:xml</span>, <span style="color:#ff3333; font-weight:bold;">:version</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;1.0&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:encoding</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;UTF-8&quot;</span>
xml.<span style="color:#9900CC;">content</span> <span style="color:#ff3333; font-weight:bold;">:type</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;hypertext&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp;
xml.<span style="color:#9900CC;">head</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  xml.<span style="color:#9900CC;">pageID</span> <span style="color:#996600;">&quot;1&quot;</span>
  xml.<span style="color:#9900CC;">title</span> <span style="color:#996600;">&quot;USSD Page from Ruby&quot;</span>
  xml.<span style="color:#9900CC;">protocol</span> <span style="color:#996600;">&quot;html,java,wap,ussd,xhtml&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
xml.<span style="color:#9900CC;">body</span> <span style="color:#006600; font-weight:bold;">&#123;</span>        
  greeting = <span style="color:#996600;">'Welcome back!'</span>
  xml.<span style="color:#CC0066; font-weight:bold;">p</span> greeting
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/rubyonrails-generating-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #9: Getting HTTP Headers</title>
		<link>/wordpress/2008/11/rubyonrails-getting-http-headers/</link>
		<comments>/wordpress/2008/11/rubyonrails-getting-http-headers/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 15:49:32 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=298</guid>
		<description><![CDATA[1. I was trying to get the http headers dump from a mobile phone. So I quickly dump it in a log file to see its contents.. headers&#91;'Content-Type'&#93; = 'text/xml; charset=utf-8' for header in request.env.select &#123;&#124;k,v&#124; k.match&#40;&#34;^HTTP.*&#34;&#41;&#125; logger.info&#40;header&#91;0&#93;.split&#40;'_',2&#41;&#91;1&#93; + &#34;:&#34; + header&#91;1&#93;&#41; end Reference: http://tonycode.com/wiki/index.php?title=Dumping_HTTP_Headers 2. However, please note that you can actually see everything]]></description>
			<content:encoded><![CDATA[<p>1. I was trying to get the http headers dump from a mobile phone. So I quickly dump it in a log file to see its contents..</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    headers<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Content-Type'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'text/xml; charset=utf-8'</span>
    <span style="color:#9966CC; font-weight:bold;">for</span> header <span style="color:#9966CC; font-weight:bold;">in</span> request.<span style="color:#9900CC;">env</span>.<span style="color:#CC0066; font-weight:bold;">select</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>k,v<span style="color:#006600; font-weight:bold;">|</span> k.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;^HTTP.*&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
        logger.<span style="color:#9900CC;">info</span><span style="color:#006600; font-weight:bold;">&#40;</span>header<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'_'</span>,<span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;:&quot;</span> <span style="color:#006600; font-weight:bold;">+</span> header<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Reference:<br />
<a href="http://tonycode.com/wiki/index.php?title=Dumping_HTTP_Headers">http://tonycode.com/wiki/index.php?title=Dumping_HTTP_Headers</a></p>
<p>2. However, please note that you can actually see everything from the request as parameters.</p>
<p> Parameters: {&#8220;MSAG-ADDRESS-PREFIX&#8221;=>&#8221;aSTARTa&#8221;, &#8220;format&#8221;=>&#8221;xml&#8221;, &#8220;protocol&#8221;=>&#8221;ussd&#8221;, &#8220;user-agent&#8221;=>&#8221;Jakarta Commons-HttpClient/3.0.1&#8243;, &#8220;WHOISD-ABONENT&#8221;=>&#8221;8613520747210&#8243;, &#8220;action&#8221;=>&#8221;menu&#8221;, &#8220;controller&#8221;=>&#8221;ussd&#8221;, &#8220;subscriberID&#8221;=>&#8221;8613520747210&#8243;, &#8220;WHOISD-USR&#8221;=>&#8221;-1&#8243;, &#8220;host&#8221;=>&#8221;wap.watago.mobi&#8221;, &#8220;WHOISD-USSD-MESSAGE&#8221;=>&#8221;", &#8220;content-length&#8221;=>&#8221;0&#8243;}</p>
<p>This means we can easily do..</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@whoisd_abonent</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'WHOISD-ABONENT'</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#0000FF; font-weight:bold;">nil</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/rubyonrails-getting-http-headers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #8: Testing with session variables</title>
		<link>/wordpress/2008/11/testing-with-session-variables/</link>
		<comments>/wordpress/2008/11/testing-with-session-variables/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 14:23:35 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=297</guid>
		<description><![CDATA[Taken from http://guides.rails.info/testing_rails_applications.html The get method kicks off the web request and populates the results into the response. It accepts 4 arguments: *The action of the controller you are requesting. This can be in the form of a string or a symbol. *An optional hash of request parameters to pass into the action (eg. query]]></description>
			<content:encoded><![CDATA[<p>Taken from <a href="http://guides.rails.info/testing_rails_applications.html">http://guides.rails.info/testing_rails_applications.html</a></p>
<p>The get method kicks off the web request and populates the results into the response. It accepts 4 arguments:</p>
<p>    *The action of the controller you are requesting. This can be in the form of a string or a symbol.<br />
    *An optional hash of request parameters to pass into the action (eg. query string parameters or post variables).<br />
    *An optional hash of session variables to pass along with the request.<br />
    *An optional hash of flash values.</p>
<p>Example: Calling the :show action, passing an id of 12 as the params and setting a user_id of 5 in the session:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">get<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:show</span>, <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">'id'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;12&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">'user_id'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">5</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/testing-with-session-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #7: NIL in Fixtures</title>
		<link>/wordpress/2008/11/be-careful-with-your-fixtures/</link>
		<comments>/wordpress/2008/11/be-careful-with-your-fixtures/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 10:19:11 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=294</guid>
		<description><![CDATA[If you want user_id to be &#8216;nil&#8217;, then omit it from your fixtures. I tried setting user_id: nil before, and it turned out to be &#8217;0&#8242; in the database. # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html &#60;% u = UserLogin.create&#40; :password =&#62; 'foo'&#41; %&#62; &#60;% u.password=&#40;'password'&#41; %&#62; &#160; user_no_profile: email: noprofile@yahoo.com admin: false user_id: nil salt:]]></description>
			<content:encoded><![CDATA[<p>If you want user_id to be &#8216;nil&#8217;, then omit it from your fixtures. I tried setting user_id: nil before, and it turned out to be &#8217;0&#8242; in the database.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"># Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
<span style="color:#006600; font-weight:bold;">&lt;%</span> u = UserLogin.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'foo'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span> u.<span style="color:#9900CC;">password</span>=<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'password'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
user_no_profile:
 email: noprofile@yahoo.com
 admin: false
 user_id: nil
 salt: <span style="color:#006600; font-weight:bold;">&lt;%</span>= u.<span style="color:#9900CC;">salt</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
 salted_password: <span style="color:#006600; font-weight:bold;">&lt;%</span>= u.<span style="color:#9900CC;">salted_password</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p><img src="/wordpress/wp-content/uploads/2008/11/picture-3.png" alt="Picture 3.png" border="0" width="640" height="60" /></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"># Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
<span style="color:#006600; font-weight:bold;">&lt;%</span> u = UserLogin.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'foo'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span> u.<span style="color:#9900CC;">password</span>=<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'password'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
user_no_profile:
 email: noprofile@yahoo.com
 admin: false
 salt: <span style="color:#006600; font-weight:bold;">&lt;%</span>= u.<span style="color:#9900CC;">salt</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
 salted_password: <span style="color:#006600; font-weight:bold;">&lt;%</span>= u.<span style="color:#9900CC;">salted_password</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p><img src="/wordpress/wp-content/uploads/2008/11/picture-21.png" alt="Picture 2.png" border="0" width="680" height="61" /></p>
<p><em>Before pulling your hair out on what went wrong with your functional tests, check the test database if you have the correct values in your records.</em>  Remember <strong>&#8217;0&#8242;</strong> is different from <strong>&#8216;nil&#8217;</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/be-careful-with-your-fixtures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #6: Pagination</title>
		<link>/wordpress/2008/11/ruby-on-rails-pagination/</link>
		<comments>/wordpress/2008/11/ruby-on-rails-pagination/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 04:15:43 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=293</guid>
		<description><![CDATA[1. will_paginate docs Main http://github.com/mislav/will_paginate/wikis Reference http://mislav.uniqpath.com/static/will_paginate/doc/ Clone URL: git://github.com/mislav/will_paginate.git 2. Installation as a gem http://github.com/mislav/will_paginate/wikis/installation gem sources -a http://gems.github.com Once installed, do script/server 3. Controller class PoiAppController &#60; ApplicationController def poi_by_category mylimit = 100 sql = &#34;SELECT pa.* FROM poi_apps pa WHERE pa.id IN &#34; + &#34;(&#34; + &#34;SELECT pc.poi_app_id &#34; + &#34;FROM poi_categories]]></description>
			<content:encoded><![CDATA[<p>1. will_paginate docs<br />
Main <a href="http://github.com/mislav/will_paginate/wikis">http://github.com/mislav/will_paginate/wikis</a><br />
Reference <a href="http://mislav.uniqpath.com/static/will_paginate/doc/">http://mislav.uniqpath.com/static/will_paginate/doc/</a><br />
Clone URL: <a href="http://mislav.uniqpath.com/static/will_paginate/doc/">git://github.com/mislav/will_paginate.git</a></p>
<p>2. Installation as a gem<br />
<a href="http://github.com/mislav/will_paginate/wikis/installation">http://github.com/mislav/will_paginate/wikis/installation</a><br />
gem sources -a http://gems.github.com</p>
<p>Once installed, do <strong>script/server</strong> </p>
<p>3. Controller</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> PoiAppController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController 
  <span style="color:#9966CC; font-weight:bold;">def</span> poi_by_category
	mylimit = <span style="color:#006666;">100</span>
    sql = <span style="color:#996600;">&quot;SELECT pa.* FROM poi_apps pa WHERE pa.id IN &quot;</span> <span style="color:#006600; font-weight:bold;">+</span>
          <span style="color:#996600;">&quot;(&quot;</span> <span style="color:#006600; font-weight:bold;">+</span>
			  <span style="color:#996600;">&quot;SELECT pc.poi_app_id &quot;</span> <span style="color:#006600; font-weight:bold;">+</span>
			  <span style="color:#996600;">&quot;FROM poi_categories pc &quot;</span> <span style="color:#006600; font-weight:bold;">+</span>
			  <span style="color:#996600;">&quot;WHERE pc.categ_node_id LIKE '&quot;</span> <span style="color:#006600; font-weight:bold;">+</span> params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:node_id</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;%%'&quot;</span> <span style="color:#006600; font-weight:bold;">+</span>
			  <span style="color:#996600;">&quot;LIMIT &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> mylimit.<span style="color:#9900CC;">to_s</span> <span style="color:#006600; font-weight:bold;">+</span>
          <span style="color:#996600;">&quot;)&quot;</span>
    <span style="color:#008000; font-style:italic;">#@poi_apps = PoiApp.find_by_sql(sql)</span>
    <span style="color:#0066ff; font-weight:bold;">@poi_apps</span> = PoiApp.<span style="color:#9900CC;">paginate_by_sql</span> <span style="color:#006600; font-weight:bold;">&#91;</span>sql<span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#ff3333; font-weight:bold;">:page</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:page</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#ff3333; font-weight:bold;">:per_page</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>4. View</p>

<div class="wp_syntax"><div class="code"><pre class="erb" style="font-family:monospace;">&lt;h2&gt;POIs&lt;/h2&gt;
&nbsp;
&lt;div clas=&quot;page_info&quot;&gt;
  &lt;%= page_entries_info @poi_apps %&gt;
&lt;/div&gt;
&nbsp;
&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;POI_APP_ID&lt;/td&gt;
    &lt;td&gt;CN_NAME&lt;/td&gt;
  	&lt;td&gt;EN_NAME&lt;/td&gt;
  &lt;/tr&gt;
	&lt;% for poi in @poi_apps %&gt;
	&lt;tr&gt;
	  &lt;td&gt;&lt;%= poi.id %&gt;&lt;/td&gt;
	  &lt;td&gt;&lt;%= poi.cn_name %&gt;&lt;/td&gt;
		&lt;td&gt;&lt;%= poi.en_name %&gt;&lt;/td&gt;
	&lt;/tr&gt;
	&lt;% end %&gt;
&lt;/table&gt;
&nbsp;
&lt;%= will_paginate @poi_apps %&gt;</pre></div></div>

<p>5. Checkout the styles <a href="http://mislav.uniqpath.com/static/will_paginate/">http://mislav.uniqpath.com/static/will_paginate/</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/ruby-on-rails-pagination/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #5: Dynamic Layouts</title>
		<link>/wordpress/2008/11/ror-dynamic-layouts/</link>
		<comments>/wordpress/2008/11/ror-dynamic-layouts/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 14:47:46 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=290</guid>
		<description><![CDATA[Wow.. everyday.. Ruby on Rails seems to amuse me.. I just figured how to seperate layouts just by having different files in the layouts/ which corresponds to a controller. If a layout file &#8220;home (home.html.erb)&#8221; exists and there is home_controller, then the home_controller would use that layout instead of application.html.erb. Now.. I haven&#8217;t validated this]]></description>
			<content:encoded><![CDATA[<p>Wow.. everyday.. Ruby on Rails seems to amuse me.. I just figured how to <strong>seperate layouts just by having different files in the layouts/ which corresponds to a controller</strong>. If a layout file &#8220;home (<em>home.html.erb</em>)&#8221; exists and there is home_controller, then the <em>home_controller</em> would use that layout instead of <em>application.html.erb</em>.</p>
<p>Now.. I haven&#8217;t validated this concept by book and would do so soon..</p>
<p><img src="/wordpress/wp-content/uploads/2008/11/picture-12.png" alt="Picture 1.png" border="0" width="253" height="543" /><br />
Fig 1</p>
<p><strong>Another way is specifying a filter&#8230;</strong></p>
<p>1. In application.rb, specify a method that displays the <em>&#8216;admin&#8217;</em> layout if the user is admin.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">def</span> load_layout
      <span style="color:#9966CC; font-weight:bold;">if</span> admin?
        <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">layout</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'admin'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>2. home_controller</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> HomeController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
  before_filter <span style="color:#ff3333; font-weight:bold;">:load_layout</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><img src="/wordpress/wp-content/uploads/2008/11/picture-2.png" alt="Picture 2.png" border="0" width="178" height="152" /><br />
Fig 2. admin.html.erb now exists in layouts/</p>
<p>Reference:<br />
<a href="http://railscasts.com/episodes/125-dynamic-layouts">http://railscasts.com/episodes/125-dynamic-layouts</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/ror-dynamic-layouts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #3: Installing Footnotes for RAILS</title>
		<link>/wordpress/2008/11/installing-textmate-footnotes/</link>
		<comments>/wordpress/2008/11/installing-textmate-footnotes/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 12:47:00 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=279</guid>
		<description><![CDATA[1. Install GIT from http://code.google.com/p/git-osx-installer/ 2. http://josevalim.blogspot.com/2008/05/footnotes-v30.html &#8211; Jose Valim is now maintaining footnotes 3. How to install? cd myapp/vendor/plugins git clone git://github.com/drnic/rails-footnotes.git footnotes rm -rf footnotes/.git In summary, you are better off installing the plugin from GIT instead of SVN if you are using rails 2.1.x or edge ( at the time this post]]></description>
			<content:encoded><![CDATA[<p>1. Install GIT from <a href="http://code.google.com/p/git-osx-installer/">http://code.google.com/p/git-osx-installer/</a></p>
<p>2. <a href="http://josevalim.blogspot.com/2008/05/footnotes-v30.html">http://josevalim.blogspot.com/2008/05/footnotes-v30.html</a> &#8211; Jose Valim is now maintaining footnotes</p>
<p>3. How to install?</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> myapp<span style="color: #000000; font-weight: bold;">/</span>vendor<span style="color: #000000; font-weight: bold;">/</span>plugins
git clone git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>drnic<span style="color: #000000; font-weight: bold;">/</span>rails-footnotes.git footnotes
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> footnotes<span style="color: #000000; font-weight: bold;">/</span>.git</pre></div></div>

<p>In summary, you are better off installing the plugin from GIT instead of SVN if you are using rails 2.1.x or edge ( at the time this post was written)</p>
<p><strong>UPDATE</strong></p>
<p>If you are receiving 500 Internal Server Error when having errors on your views then please read below..</p>
<p>If you are running on Rails 2.1.x, you should use Footnotes v3.2.2:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">    <span style="color: #7a0874; font-weight: bold;">cd</span> myapp
    git clone git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>drnic<span style="color: #000000; font-weight: bold;">/</span>rails-footnotes.git vendor<span style="color: #000000; font-weight: bold;">/</span>plugins<span style="color: #000000; font-weight: bold;">/</span>footnotes
    <span style="color: #7a0874; font-weight: bold;">cd</span> vendor<span style="color: #000000; font-weight: bold;">/</span>plugins<span style="color: #000000; font-weight: bold;">/</span>footnotes
    git checkout v3.2.2
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> .<span style="color: #000000; font-weight: bold;">/</span>.git</pre></div></div>

<p>If you are running on Rails 2.0.x or Rails 1.x, you should use Footnotes v3.0:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">    <span style="color: #7a0874; font-weight: bold;">cd</span> myapp
    git clone git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>drnic<span style="color: #000000; font-weight: bold;">/</span>rails-footnotes.git vendor<span style="color: #000000; font-weight: bold;">/</span>plugins<span style="color: #000000; font-weight: bold;">/</span>footnotes
    <span style="color: #7a0874; font-weight: bold;">cd</span> vendor<span style="color: #000000; font-weight: bold;">/</span>plugins<span style="color: #000000; font-weight: bold;">/</span>footnotes
    git checkout v3.0
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> .<span style="color: #000000; font-weight: bold;">/</span>.git</pre></div></div>

<p>Remember that in Rails 1.x, after filters appear first than before filters in the Filters tab.</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/installing-textmate-footnotes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #2: Links</title>
		<link>/wordpress/2008/11/ruby-on-rails-links/</link>
		<comments>/wordpress/2008/11/ruby-on-rails-links/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 23:52:04 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=278</guid>
		<description><![CDATA[Ruby References Ruby Quick Reference http://www.zenspider.com/Languages/Ruby/QuickRef.html Rails References Downloadable Rails API with Javascript http://www.railsbrain.com/ (Preferred) Official Rails API http://api.rubyonrails.org/ GotAPI http://www.gotapi.com/html Naming Conventions RubyOnRails Naming Conventions from ITSignals http://itsignals.cascadia.com.au/?p=7 RubyOnRails.org TipSheetForBeginners http://wiki.rubyonrails.org/rails/pages/TipSheetForBeginners Tutorials AkitaOnRails: Rails 2.0 First Full Tutorial http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial Blogs AkitaOnRails http://www.akitaonrails.com Books The Ruby Way http://rubyhacker.com/]]></description>
			<content:encoded><![CDATA[<p><strong>Ruby References</strong></p>
<p>Ruby Quick Reference<br />
<a href="http://www.zenspider.com/Languages/Ruby/QuickRef.html">http://www.zenspider.com/Languages/Ruby/QuickRef.html</a></p>
<p><strong>Rails References</strong></p>
<p>Downloadable Rails API with Javascript <a href="http://www.railsbrain.com/">http://www.railsbrain.com/</a> (Preferred)</p>
<p>Official Rails API <a href="http://api.rubyonrails.org/">http://api.rubyonrails.org/</a></p>
<p>GotAPI<br />
<a href="http://www.gotapi.com/html">http://www.gotapi.com/html</a></p>
<p><strong>Naming Conventions</strong></p>
<p>RubyOnRails Naming Conventions from ITSignals<br />
<a href="http://itsignals.cascadia.com.au/?p=7">http://itsignals.cascadia.com.au/?p=7</a></p>
<p>RubyOnRails.org TipSheetForBeginners<br />
<a href="http://wiki.rubyonrails.org/rails/pages/TipSheetForBeginners">http://wiki.rubyonrails.org/rails/pages/TipSheetForBeginners</a></p>
<p><strong>Tutorials</strong></p>
<p>AkitaOnRails: Rails 2.0 First Full Tutorial<br />
<a href="http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial">http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial</a></p>
<p><strong>Blogs</strong></p>
<p>AkitaOnRails<br />
<a href="http://www.akitaonrails.com">http://www.akitaonrails.com</a></p>
<p><strong>Books</strong></p>
<p>The Ruby Way<br />
<a href="http://rubyhacker.com/">http://rubyhacker.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/ruby-on-rails-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Note #1: Getting my feet wet in Ruby On Rails</title>
		<link>/wordpress/2008/11/getting-my-feet-wet-in-ruby-on-rails/</link>
		<comments>/wordpress/2008/11/getting-my-feet-wet-in-ruby-on-rails/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 22:23:56 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">/wordpress/?p=277</guid>
		<description><![CDATA[1. Just installed Ruby and Rails on my MacOSX Leopard. The current version of rails is 1.2.6. I wanted to upgrade using gem update &#8211;system but it seems like taking forever.. So I did a manual install of ruby, rubygems then rails.. 2. The tutorial that I followed was from http://hivelogic.com/articles/2008/02/ruby-rails-leopard Installation Summary 2.1 ruby]]></description>
			<content:encoded><![CDATA[<p>1.  Just installed Ruby and Rails on my MacOSX Leopard. The current version of rails is 1.2.6. I wanted to upgrade using gem update &#8211;system but it seems like taking forever.. So I did a manual install of ruby, rubygems then rails..</p>
<p>2.  The tutorial that I followed was from <a href="http://hivelogic.com/articles/2008/02/ruby-rails-leopard">http://hivelogic.com/articles/2008/02/ruby-rails-leopard</a></p>
<p>Installation Summary</p>
<p>2.1 ruby</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>ftp.ruby-lang.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>ruby-1.8.6-p286.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zxvf</span> ruby-1.8.6-p286.tar.gz
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>2.2 rubygems</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>frs<span style="color: #000000; font-weight: bold;">/</span>download.php<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">45905</span><span style="color: #000000; font-weight: bold;">/</span>rubygems-1.3.1.tgz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zxvf</span> rubygems-1.3.1.tgz
ruby setup.rb</pre></div></div>

<p>2.3 rails</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-V</span> rails</pre></div></div>

<p>2.4 other gems</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rubygems-update
gem <span style="color: #c20cb9; font-weight: bold;">install</span> mongrel
gem <span style="color: #c20cb9; font-weight: bold;">install</span> capistrano
gem <span style="color: #c20cb9; font-weight: bold;">install</span> postgres
gem <span style="color: #c20cb9; font-weight: bold;">install</span> builder</pre></div></div>

<p>3.  Browsed the first few pages of the hilarious <a href="http://www.poignantguide.net/ruby">http://www.poignantguide.net/ruby</a></p>
<p>4. Went for a book. Found Simply Rails 2.0 on Boox24x7 and Safari. Added that to my shelf and read chapters 1 &#8211; 5 on my first night.</p>
<p>5. Was able to setup database configuration in config/database.yml using Postgres. I have yet to study how oracle works.</p>
<p>6. <strong>rake db:migrate</strong> is a convenient way of building your database schema without using SQL. Simply Rails 2.0:Chapter 5:Generating a Model introduced inserting records using <strong>script/console</strong></p>
<p>7. URL Helpers for Story Resource<br />
stories_path				/stories<br />
new_story_path			/stories/new<br />
story_path(@story) 		/stories/1<br />
edit_story_path(@story) 	/stories/1/edit</p>
<p>Remember to define the route in config/routes.rb<br />
<strong>map.resources :users, :categories</strong></p>
<p>8. Naming Conventions<br />
<img src="/wordpress/wp-content/uploads/2008/11/picture-1.png" alt="Picture 1.png" border="0" width="340" height="326" /></p>
<p>Variables &#8211; lowercase letters and words separated by underscores.<br />
i.e name, country_of_origin</p>
<p>DB Table and Column names should follow convention is always pluralised.<br />
i.e users</p>
<p>Classes and Modules &#8211; no underscores and each word is capitalized<br />
i.e User, UserCategories</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/11/getting-my-feet-wet-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
