<?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>skater coder &#187; Rails</title>
	<atom:link href="http://www.skatercoder.com/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.skatercoder.com</link>
	<description>angela chng - Ruby on Rails / PHP web developer &#38; skater girl in Singapore</description>
	<lastBuildDate>Wed, 18 May 2011 06:35:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Commonly used Rails 2.3 commands</title>
		<link>http://www.skatercoder.com/2010/08/31/commonly-used-rails-2-3-command-line/</link>
		<comments>http://www.skatercoder.com/2010/08/31/commonly-used-rails-2-3-command-line/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 05:43:58 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[rails 2.3.5]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=419</guid>
		<description><![CDATA[Rails 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Setup rails app with mysql $ rails appname -d mysql &#160; Start server with debugging enabled $ script/server --debugger &#160; Start server with debugging enabled [...]]]></description>
			<content:encoded><![CDATA[<h2>Rails</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Setup rails app with mysql
$ rails appname <span style="color: #660033;">-d</span> mysql
&nbsp;
Start server with debugging enabled
$ script<span style="color: #000000; font-weight: bold;">/</span>server <span style="color: #660033;">--debugger</span>
&nbsp;
Start server with debugging enabled - specify environment
$ script<span style="color: #000000; font-weight: bold;">/</span>server <span style="color: #660033;">--debugger</span> <span style="color: #007800;">RAILS_ENV</span>=production
&nbsp;
Install required gems
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> rake gems:<span style="color: #c20cb9; font-weight: bold;">install</span>
&nbsp;
Run gem server <span style="color: #000000; font-weight: bold;">for</span> rdocs
$ gem server
&nbsp;
View routes 
$ rake routes
&nbsp;
Update Rails
$ rake rails:update
&nbsp;
Enter the console with specified environment
$ script<span style="color: #000000; font-weight: bold;">/</span>console
$ script<span style="color: #000000; font-weight: bold;">/</span>console development
$ script<span style="color: #000000; font-weight: bold;">/</span>console <span style="color: #7a0874; font-weight: bold;">test</span>
$ script<span style="color: #000000; font-weight: bold;">/</span>console production
&nbsp;
Clear logfiles
$ rake log:<span style="color: #c20cb9; font-weight: bold;">clear</span></pre></td></tr></table></div>

<h2>Database</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Create database
$ rake db:create
&nbsp;
Run database migrations
$ rake db:migrate
&nbsp;
Drop database
$ rake db:drop
&nbsp;
Rollback database migration
$ rake db:rollback</pre></td></tr></table></div>

<h2>Testing</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Clone database <span style="color: #000000; font-weight: bold;">for</span> testing
$ rake db:<span style="color: #7a0874; font-weight: bold;">test</span>:clone
&nbsp;
Bootstrap Rspec
$ script<span style="color: #000000; font-weight: bold;">/</span>generate rspec
&nbsp;
Bootstrap Cucumber
$ script<span style="color: #000000; font-weight: bold;">/</span>generate cucumber <span style="color: #660033;">--rspec</span> <span style="color: #660033;">--capybara</span> <span style="color: #660033;">--spork</span>
&nbsp;
Bootstrap Pickle
$ script<span style="color: #000000; font-weight: bold;">/</span>generate pickle
&nbsp;
Generate Rspec model
$ script<span style="color: #000000; font-weight: bold;">/</span>generate rspec_model singularmodelname
&nbsp;
Generate Rspec controller
$ script<span style="color: #000000; font-weight: bold;">/</span>generate rspec_controller pluralmodelname
&nbsp;
Start spork <span style="color: #000000; font-weight: bold;">for</span> cucumber
$ spork cuc
&nbsp;
Run autotest
$ autotest</pre></td></tr></table></div>

<h2>Gems</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Install gems
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> gemname
&nbsp;
Uninstall gems
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem uninstall gemname
&nbsp;
Reinstall gems
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem pristine <span style="color: #660033;">--all</span>
&nbsp;
Remove old gems
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem clean</pre></td></tr></table></div>

<h2>Generators</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Generate migration
$ script<span style="color: #000000; font-weight: bold;">/</span>generate migration the_migration_name</pre></td></tr></table></div>

<h2>Heroku</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Push to Git
$ <span style="color: #c20cb9; font-weight: bold;">git</span> push heroku</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/08/31/commonly-used-rails-2-3-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comma Separated List in Rails</title>
		<link>http://www.skatercoder.com/2010/07/25/comma-separated-list-in-rails/</link>
		<comments>http://www.skatercoder.com/2010/07/25/comma-separated-list-in-rails/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 17:14:01 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[l]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=391</guid>
		<description><![CDATA[Here&#8217;s a useful tip I found from http://ariejan.net/2007/03/27/rails-tip-snippet-create-a-comma-seperate-list/ To get &#8216;Tom, Dick, Harry&#8217; 1 @users.collect&#123;&#124;u&#124; u.name&#125;.join&#40;', '&#41; To get &#8216;Tom, Dick and Harry&#8217; 1 @users.collect&#40;&#38;:name&#41;.to_sentence]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a useful tip I found from <a href="http://ariejan.net/2007/03/27/rails-tip-snippet-create-a-comma-seperate-list/">http://ariejan.net/2007/03/27/rails-tip-snippet-create-a-comma-seperate-list/</a></p>
<p>To get &#8216;Tom, Dick, Harry&#8217;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@users</span>.<span style="color:#9900CC;">collect</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>u<span style="color:#006600; font-weight:bold;">|</span> u.<span style="color:#9900CC;">name</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">', '</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>To get &#8216;Tom, Dick and Harry&#8217;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@users</span>.<span style="color:#9900CC;">collect</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&amp;</span>:name<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_sentence</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/07/25/comma-separated-list-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Create a Rails model that has categories and subcategories</title>
		<link>http://www.skatercoder.com/2010/07/23/how-to-create-a-rails-model-that-has-categories-and-subcategories/</link>
		<comments>http://www.skatercoder.com/2010/07/23/how-to-create-a-rails-model-that-has-categories-and-subcategories/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 05:57:37 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[acts_as_tree]]></category>
		<category><![CDATA[categories]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=384</guid>
		<description><![CDATA[Another reason to love rails, it&#8217;s so easy! Just install the acts_as_tree plugin 1 $ script/plugin install git://github.com/rails/acts_as_tree.git and in your model, eg. app/models/category.rb, just add 1 acts_as_tree :order =&#62; 'name' And here&#8217;s the plugin&#8217;s readme on how to use it 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [...]]]></description>
			<content:encoded><![CDATA[<p>Another reason to love rails, it&#8217;s so easy!</p>
<p>Just install the <a href="http://github.com/rails/acts_as_tree" target="_blank">acts_as_tree plugin</a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ script<span style="color: #000000; font-weight: bold;">/</span>plugin <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>rails<span style="color: #000000; font-weight: bold;">/</span>acts_as_tree.git</pre></td></tr></table></div>

<p>and in your model, eg. <strong>app/models/category.rb</strong>, just add</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">acts_as_tree <span style="color:#ff3333; font-weight:bold;">:order</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'name'</span></pre></td></tr></table></div>

<p>And here&#8217;s the plugin&#8217;s readme on how to use it</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">acts_as_tree
============
&nbsp;
Specify this <span style="color:#006600; font-weight:bold;">+</span>acts_as<span style="color:#006600; font-weight:bold;">+</span> extension <span style="color:#9966CC; font-weight:bold;">if</span> you want to model a tree structure by providing a parent association <span style="color:#9966CC; font-weight:bold;">and</span> a children
association. <span style="color:#9900CC;">This</span> requires that you have a foreign key column, which by default is called <span style="color:#006600; font-weight:bold;">+</span>parent_id<span style="color:#006600; font-weight:bold;">+</span>.
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">class</span> Category <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
    acts_as_tree <span style="color:#ff3333; font-weight:bold;">:order</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;name&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  Example:
  root
   \_ child1
        \_ subchild1
        \_ subchild2
&nbsp;
  root      = Category.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;name&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;root&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  child1    = root.<span style="color:#9900CC;">children</span>.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;name&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;child1&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  subchild1 = child1.<span style="color:#9900CC;">children</span>.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;name&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;subchild1&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  root.<span style="color:#9900CC;">parent</span>   <span style="color:#008000; font-style:italic;"># =&gt; nil</span>
  child1.<span style="color:#9900CC;">parent</span> <span style="color:#008000; font-style:italic;"># =&gt; root</span>
  root.<span style="color:#9900CC;">children</span> <span style="color:#008000; font-style:italic;"># =&gt; [child1]</span>
  root.<span style="color:#9900CC;">children</span>.<span style="color:#9900CC;">first</span>.<span style="color:#9900CC;">children</span>.<span style="color:#9900CC;">first</span> <span style="color:#008000; font-style:italic;"># =&gt; subchild1</span></pre></td></tr></table></div>

<p><strong>Resources</strong></p>
<ul>
<li><a href="http://railscasts.com/episodes/162-tree-based-navigation" target="_blank">Railscasts &#8211; Tree Based Navigation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/07/23/how-to-create-a-rails-model-that-has-categories-and-subcategories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Receive email in rails with mail fetcher</title>
		<link>http://www.skatercoder.com/2010/07/23/how-to-receive-email-in-rails-with-mail-fetcher/</link>
		<comments>http://www.skatercoder.com/2010/07/23/how-to-receive-email-in-rails-with-mail-fetcher/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 16:46:26 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[action mailer]]></category>
		<category><![CDATA[mail fetcher]]></category>
		<category><![CDATA[receive email]]></category>

		<guid isPermaLink="false">http://roadburn.audioreload.com/?p=362</guid>
		<description><![CDATA[Dan Weinand and Luke Francl have written a nice plugin which simplifies the task of retrieving emails. Kudos to them! So basically what you need to do is install the plugin, create the Action Mailer receiver, and then use cron to schedule the script to run Here are the steps: First install the fetcher plugin [...]]]></description>
			<content:encoded><![CDATA[<p>Dan Weinand and Luke Francl have written a nice plugin which simplifies the task of retrieving emails. Kudos to them!</p>
<p>So basically what you need to do is install the plugin, create the Action Mailer receiver, and then use cron to schedule the script to run</p>
<p>Here are the steps:</p>
<p>First install the fetcher plugin from <a href="http://github.com/look/fetcher/" target="_blank">http://github.com/look/fetcher/</a> and SystemTimer gem it requires</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ script<span style="color: #000000; font-weight: bold;">/</span>plugin <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>look<span style="color: #000000; font-weight: bold;">/</span>fetcher.git
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> SystemTimer</pre></div></div>

<p>Create your ruby script eg. <strong>script/mail_fetcher</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/../config/environment.rb'</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'system_timer'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'yaml'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'fetcher'</span>
&nbsp;
&nbsp;
<span style="color:#9966CC; font-weight:bold;">begin</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Start checking email&quot;</span>
&nbsp;
  Lockfile.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'cron_mail_fetcher.lock'</span>, <span style="color:#ff3333; font-weight:bold;">:retries</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    config = <span style="color:#CC00FF; font-weight:bold;">YAML</span>.<span style="color:#9900CC;">load_file</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{RAILS_ROOT}/config/mail.yml&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    config = config<span style="color:#006600; font-weight:bold;">&#91;</span>RAILS_ENV<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_options</span>
&nbsp;
    fetcher = Fetcher.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span>:receiver <span style="color:#006600; font-weight:bold;">=&gt;</span> EnquiryMailer<span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span>config<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    fetcher.<span style="color:#9900CC;">fetch</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#6666ff; font-weight:bold;">Lockfile::MaxTriesLockError</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> e
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Another fetcher is already running. Exiting.&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Create the <strong>config/mail.yml</strong> file</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">defaults: <span style="color:#006600; font-weight:bold;">&amp;</span>defaults
  <span style="color:#008000; font-style:italic;"># Settings for gmail</span>
  type: imap                <span style="color:#008000; font-style:italic;"># pop OR imap</span>
  server: imap.<span style="color:#9900CC;">gmail</span>.<span style="color:#9900CC;">com</span>  <span style="color:#008000; font-style:italic;"># server hostname</span>
  port: <span style="color:#006666;">993</span>                 <span style="color:#008000; font-style:italic;"># 993 for IMAPs</span>
  ssl: <span style="color:#0000FF; font-weight:bold;">true</span>                 <span style="color:#008000; font-style:italic;"># Remove if not using SSL</span>
  username: user@gmail.<span style="color:#9900CC;">com</span>    <span style="color:#008000; font-style:italic;"># Username</span>
  password: xxx                <span style="color:#008000; font-style:italic;"># Password</span>
  use_login: <span style="color:#0000FF; font-weight:bold;">true</span>           <span style="color:#008000; font-style:italic;"># Required for GMAIL</span>
  processed_folder: processed
  error_folder: error
&nbsp;
 <span style="color:#008000; font-style:italic;"># settings for bluehost</span>
  type: imap                <span style="color:#008000; font-style:italic;"># pop OR imap</span>
  server: boxXXX.<span style="color:#9900CC;">bluehost</span>.<span style="color:#9900CC;">com</span>  <span style="color:#008000; font-style:italic;"># server hostname</span>
  port: <span style="color:#006666;">993</span>                 <span style="color:#008000; font-style:italic;"># 993 for IMAPs</span>
  ssl: <span style="color:#0000FF; font-weight:bold;">true</span>                 <span style="color:#008000; font-style:italic;"># Remove if not using SSL</span>
  username: user@domain.<span style="color:#9900CC;">com</span>    <span style="color:#008000; font-style:italic;"># Username</span>
  password: xxx                <span style="color:#008000; font-style:italic;"># Password</span>
  use_login: <span style="color:#0000FF; font-weight:bold;">true</span>
  processed_folder: INBOX.<span style="color:#9900CC;">processed</span>
  error_folder: INBOX.<span style="color:#9900CC;">error</span>
&nbsp;
development:
  <span style="color:#006600; font-weight:bold;">&lt;&lt;</span>: <span style="color:#006600; font-weight:bold;">*</span>defaults
  <span style="color:#008000; font-style:italic;"># Override other values here</span>
&nbsp;
test:
  <span style="color:#006600; font-weight:bold;">&lt;&lt;</span>: <span style="color:#006600; font-weight:bold;">*</span>defaults
  <span style="color:#008000; font-style:italic;"># Override other values here</span>
&nbsp;
production:
  <span style="color:#006600; font-weight:bold;">&lt;&lt;</span>: <span style="color:#006600; font-weight:bold;">*</span>defaults
  <span style="color:#008000; font-style:italic;"># Override other values here</span></pre></div></div>

<p>Create your Action Mailer</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 mailer EnquiryMailer</pre></div></div>

<p>Add the receiver in <strong>app/models/enquiry_mailer.rb</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> EnquiryMailer <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActionMailer::Base</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> receive<span style="color:#006600; font-weight:bold;">&#40;</span>email<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#008000; font-style:italic;"># do whatever you want with the email here</span>
    <span style="color:#008000; font-style:italic;"># you can use:</span>
    <span style="color:#008000; font-style:italic;"># email.subject, email.from, email.body</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Run the script</p>

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

<p>Then follow Ryan Bate&#8217;s screencast on how to use <a href="http://railscasts.com/episodes/164-cron-in-ruby" target="blank">Cron in Ruby</a></p>
<p><strong>Resources</strong></p>
<ul>
<li><a href="http://guides.rubyonrails.org/action_mailer_basics.html" target="_blank">http://guides.rubyonrails.org/action_mailer_basics.html</a></li>
<li><a href="http://railspikes.com/2007/6/1/rails-email-processing" target="_blank">http://railspikes.com/2007/6/1/rails-email-processing</a></li>
<li><a href="http://railscasts.com/episodes/164-cron-in-ruby" target="blank">Railscasts: Cron in Ruby</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/07/23/how-to-receive-email-in-rails-with-mail-fetcher/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails fetcher mail.yml IMAP setting for bluehost</title>
		<link>http://www.skatercoder.com/2010/07/21/rails-fetcher-mail-yml-imap-setting-for-bluehost/</link>
		<comments>http://www.skatercoder.com/2010/07/21/rails-fetcher-mail-yml-imap-setting-for-bluehost/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 18:42:40 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[bluehost]]></category>
		<category><![CDATA[fetcher]]></category>
		<category><![CDATA[imap]]></category>

		<guid isPermaLink="false">http://roadburn.audioreload.com/?p=302</guid>
		<description><![CDATA[I was getting this error when trying to create a mailbox using create(mailbox) from Net::IMAP 1 /opt/local/lib/ruby/1.8/net/imap.rb:981:in `pick_up_tagged_response': Unknown namespace. (Net::IMAP::NoResponseError) Realised that the processed and error mailboxes names had to be appended to &#8220;INBOX.&#8221; 1 2 3 4 5 6 7 8 9 type: imap server: boxXXX.bluehost.com port: 993 ssl: true username: username@domain.com password: [...]]]></description>
			<content:encoded><![CDATA[<p>I was getting this error when trying to create a mailbox using create(mailbox) from Net::IMAP</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>opt<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><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>net<span style="color: #000000; font-weight: bold;">/</span>imap.rb:<span style="color: #000000;">981</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>pick_up_tagged_response<span style="color: #ff0000;">': Unknown namespace. (Net::IMAP::NoResponseError)</span></pre></td></tr></table></div>

<p>Realised that the processed and error mailboxes names had to be appended to &#8220;INBOX.&#8221;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">type: imap            
server: boxXXX.<span style="color:#9900CC;">bluehost</span>.<span style="color:#9900CC;">com</span>  
port: <span style="color:#006666;">993</span>                
ssl: <span style="color:#0000FF; font-weight:bold;">true</span>               
username: username@domain.<span style="color:#9900CC;">com</span> 
password: xxx
use_login: <span style="color:#0000FF; font-weight:bold;">true</span>        
processed_folder: INBOX.<span style="color:#9900CC;">processed</span>
error_folder: INBOX.<span style="color:#9900CC;">error</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/07/21/rails-fetcher-mail-yml-imap-setting-for-bluehost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Install Memcached on Ubuntu for Rails</title>
		<link>http://www.skatercoder.com/2009/02/18/installing-memcached-on-ubuntu-for-rails/</link>
		<comments>http://www.skatercoder.com/2009/02/18/installing-memcached-on-ubuntu-for-rails/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 04:16:02 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[memcached]]></category>

		<guid isPermaLink="false">http://roadburn.audioreload.com/?p=260</guid>
		<description><![CDATA[1 2 3 4 5 6 7 sudo aptitude install memcached &#160; sudo aptitude install libmemcache-dev &#160; sudo gem install RubyInline &#160; sudo gem install memcache-client in application.rb Uncomment the protect_from_forgery in environment.rb 1 2 3 4 5 6 7 8 9 CACHE = MemCache.new 'localhost:11211', :namespace =&#38;gt; 'your_app' &#160; config.action_controller.session = &#123; :session_key =&#62; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> memcached
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libmemcache-dev
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> RubyInline
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> memcache-client</pre></td></tr></table></div>

<p><strong>in application.rb</strong></p>
<p>Uncomment the protect_from_forgery</p>
<p><strong>in environment.rb</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">CACHE = MemCache.<span style="color:#9900CC;">new</span> <span style="color:#996600;">'localhost:11211'</span>, <span style="color:#ff3333; font-weight:bold;">:namespace</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">'your_app'</span>
&nbsp;
config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
<span style="color:#ff3333; font-weight:bold;">:session_key</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'_your_app_session'</span>,
<span style="color:#ff3333; font-weight:bold;">:secret</span>      <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'yoursecrectkey'</span>,
<span style="color:#ff3333; font-weight:bold;">:cache</span>       <span style="color:#006600; font-weight:bold;">=&gt;</span> CACHE,
<span style="color:#ff3333; font-weight:bold;">:expires</span><span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">900</span>  <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session_store</span> = <span style="color:#ff3333; font-weight:bold;">:mem_cache_store</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2009/02/18/installing-memcached-on-ubuntu-for-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Attach images in rails</title>
		<link>http://www.skatercoder.com/2008/12/25/attach-images-in-rails/</link>
		<comments>http://www.skatercoder.com/2008/12/25/attach-images-in-rails/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 08:01:16 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://roadburn.audioreload.com/?p=253</guid>
		<description><![CDATA[View the railscast on using thoughtbot&#8217;s paperclip http://railscasts.com/episodes/134-paperclip or attach multiple images to a model using polymorphic paperclip http://burm.net/2008/10/17/ruby-on-rails-polymorphic-paperclip-plugin-tutorial/]]></description>
			<content:encoded><![CDATA[<p>View the railscast on using thoughtbot&#8217;s paperclip</p>
<p><a href="http://railscasts.com/episodes/134-paperclip">http://railscasts.com/episodes/134-paperclip</a></p>
<p>or</p>
<p>attach multiple images to a model using polymorphic paperclip</p>
<p><a href="http://burm.net/2008/10/17/ruby-on-rails-polymorphic-paperclip-plugin-tutorial/">http://burm.net/2008/10/17/ruby-on-rails-polymorphic-paperclip-plugin-tutorial/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2008/12/25/attach-images-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning how to use Shoulda</title>
		<link>http://www.skatercoder.com/2008/12/15/learning-how-to-use-shoulda/</link>
		<comments>http://www.skatercoder.com/2008/12/15/learning-how-to-use-shoulda/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 07:59:19 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[shoulda]]></category>

		<guid isPermaLink="false">http://roadburn.audioreload.com/?p=248</guid>
		<description><![CDATA[View the conf video to find out what Shoulda is http://mwrc2008.confreaks.com/12saleh.html Shoulda Walkthrough http://technicalpickles.com/posts/a-walk-through-of-test-driven-development-with-shoulda Read the thoughtbot tutorials http://thoughtbot.com/projects/shoulda/tutorial]]></description>
			<content:encoded><![CDATA[<p>View the conf video to find out what Shoulda is</p>
<p><a href="http://mwrc2008.confreaks.com/12saleh.html">http://mwrc2008.confreaks.com/12saleh.html</a></p>
<p>Shoulda Walkthrough</p>
<p><a href="http://technicalpickles.com/posts/a-walk-through-of-test-driven-development-with-shoulda">http://technicalpickles.com/posts/a-walk-through-of-test-driven-development-with-shoulda</a></p>
<p>Read the thoughtbot tutorials</p>
<p><a href="http://thoughtbot.com/projects/shoulda/tutorial">http://thoughtbot.com/projects/shoulda/tutorial</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2008/12/15/learning-how-to-use-shoulda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails export to excel spreadsheet</title>
		<link>http://www.skatercoder.com/2008/12/08/rails-export-to-excel-spreadsheet/</link>
		<comments>http://www.skatercoder.com/2008/12/08/rails-export-to-excel-spreadsheet/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 18:13:28 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[excel]]></category>

		<guid isPermaLink="false">http://roadburn.audioreload.com/?p=244</guid>
		<description><![CDATA[1 $ sudo gem install spreadsheet More help: http://codeclimber.blogspot.com/2008/11/reporting-in-excel-with-rails.html http://spreadsheet.rubyforge.org/ To send and save through browser Taken from https://rubyforge.org/forum/forum.php?thread_id=29606&#38;forum_id=2920 1 2 3 4 require 'stringio' data = StringIO.new '' book.write data send_data data.string, :type=&#62; &#34;application/excel&#34;, :disposition=&#62; 'attachment', :filename =&#62; 'MeaningfulName.xls']]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td 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> spreadsheet</pre></td></tr></table></div>

<p>More help:</p>
<p><a href="http://codeclimber.blogspot.com/2008/11/reporting-in-excel-with-rails.html">http://codeclimber.blogspot.com/2008/11/reporting-in-excel-with-rails.html</a></p>
<p><a href="http://spreadsheet.rubyforge.org/">http://spreadsheet.rubyforge.org/</a></p>
<p>To send and save through browser</p>
<p>Taken from https://rubyforge.org/forum/forum.php?thread_id=29606&amp;forum_id=2920</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'stringio'</span>
data = <span style="color:#CC00FF; font-weight:bold;">StringIO</span>.<span style="color:#9900CC;">new</span> <span style="color:#996600;">''</span>
book.<span style="color:#9900CC;">write</span> data
send_data data.<span style="color:#CC0066; font-weight:bold;">string</span>, <span style="color:#ff3333; font-weight:bold;">:type</span><span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;application/excel&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:disposition</span><span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'attachment'</span>, <span style="color:#ff3333; font-weight:bold;">:filename</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'MeaningfulName.xls'</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2008/12/08/rails-export-to-excel-spreadsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Send email in rails</title>
		<link>http://www.skatercoder.com/2008/12/04/send-email-in-rails/</link>
		<comments>http://www.skatercoder.com/2008/12/04/send-email-in-rails/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 10:30:25 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[email]]></category>

		<guid isPermaLink="false">http://roadburn.audioreload.com/?p=242</guid>
		<description><![CDATA[http://railscasts.com/episodes/61]]></description>
			<content:encoded><![CDATA[<p><a href="http://railscasts.com/episodes/61">http://railscasts.com/episodes/61</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2008/12/04/send-email-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

