<?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</title>
	<atom:link href="http://www.skatercoder.com/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, 09 May 2012 18:53:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>RRAR.ME Launched</title>
		<link>http://www.skatercoder.com/2012/05/10/rrar-me-launched/</link>
		<comments>http://www.skatercoder.com/2012/05/10/rrar-me-launched/#comments</comments>
		<pubDate>Wed, 09 May 2012 18:52:12 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Portfolio]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=510</guid>
		<description><![CDATA[Messages from the Universe to you :) A personal project with Web Designer Jeannie Neo www.rrar.me]]></description>
			<content:encoded><![CDATA[<p>Messages from the Universe to you :)</p>
<p>A personal project with Web Designer Jeannie Neo</p>
<p><a href="http://www.rrar.me" target="_blank"><img src="http://www.skatercoder.com/wp-content/uploads/2012/05/Screen-shot-2012-05-10-at-AM-02.48.43-600x339.jpg" alt="" title="Screen shot 2012-05-10 at AM 02.48.43" width="600" height="339" class="alignnone size-medium wp-image-511" /></a></p>
<p><a href="http://www.rrar.me" target="_blank">www.rrar.me</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2012/05/10/rrar-me-launched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 3.2.1 Rspec and Capybara</title>
		<link>http://www.skatercoder.com/2012/03/23/rails-3-2-1-rspec-and-capybara/</link>
		<comments>http://www.skatercoder.com/2012/03/23/rails-3-2-1-rspec-and-capybara/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 09:27:16 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=504</guid>
		<description><![CDATA[Gemfile 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 gem &#34;rspec-rails&#34;, :group =&#62; &#91;:test, :development&#93; &#160; group :test do gem 'factory_girl_rails', :require =&#62; false gem &#34;capybara&#34; gem &#34;capybara-webkit&#34; gem 'growl' gem &#34;spork&#34; gem &#34;guard&#34; gem &#34;guard-bundler&#34; gem &#34;guard-rspec&#34; gem &#34;guard-spork&#34; gem &#34;launchy&#34; gem &#34;database_cleaner&#34; end Commands to run [...]]]></description>
			<content:encoded><![CDATA[<p>Gemfile</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
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #ff0000;">&quot;rspec-rails&quot;</span>, :group =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>:<span style="color: #7a0874; font-weight: bold;">test</span>, :development<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
group :<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000; font-weight: bold;">do</span>
  gem <span style="color: #ff0000;">'factory_girl_rails'</span>, :require =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">false</span>
  gem <span style="color: #ff0000;">&quot;capybara&quot;</span>
  gem <span style="color: #ff0000;">&quot;capybara-webkit&quot;</span>
  gem <span style="color: #ff0000;">'growl'</span>  
  gem <span style="color: #ff0000;">&quot;spork&quot;</span>
  gem <span style="color: #ff0000;">&quot;guard&quot;</span>
  gem <span style="color: #ff0000;">&quot;guard-bundler&quot;</span>
  gem <span style="color: #ff0000;">&quot;guard-rspec&quot;</span>
  gem <span style="color: #ff0000;">&quot;guard-spork&quot;</span>
  gem <span style="color: #ff0000;">&quot;launchy&quot;</span>
  gem <span style="color: #ff0000;">&quot;database_cleaner&quot;</span>
end</pre></td></tr></table></div>

<p>Commands to run</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="bash" style="font-family:monospace;">brew <span style="color: #c20cb9; font-weight: bold;">install</span> qt
&nbsp;
rails g rspec:<span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> spec<span style="color: #000000; font-weight: bold;">/</span>support spec<span style="color: #000000; font-weight: bold;">/</span>models spec<span style="color: #000000; font-weight: bold;">/</span>routing
bundle <span style="color: #7a0874; font-weight: bold;">exec</span> guard init rspec
gem <span style="color: #c20cb9; font-weight: bold;">install</span> rb-fsevent
&nbsp;
spork rspec <span style="color: #660033;">--bootstrap</span>
bundle <span style="color: #7a0874; font-weight: bold;">exec</span> guard</pre></td></tr></table></div>

<p>Guardfile</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
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">guard <span style="color: #ff0000;">'bundler'</span> <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'Gemfile'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
end
&nbsp;
guard <span style="color: #ff0000;">'spork'</span>, <span style="color: #7a0874; font-weight: bold;">wait</span>: <span style="color: #000000;">60</span>, cucumber: <span style="color: #c20cb9; font-weight: bold;">false</span>, rspec: <span style="color: #c20cb9; font-weight: bold;">true</span>, test_unit: <span style="color: #c20cb9; font-weight: bold;">false</span> <span style="color: #000000; font-weight: bold;">do</span>    
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'config/application.rb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'config/environment.rb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>^config<span style="color: #000000; font-weight: bold;">/</span>environments<span style="color: #000000; font-weight: bold;">/</span>.+\.rb$<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>^config<span style="color: #000000; font-weight: bold;">/</span>initializers<span style="color: #000000; font-weight: bold;">/</span>.+\.rb$<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'Gemfile'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'Gemfile.lock'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'spec/spec_helper.rb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> :rspec <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'test/test_helper.rb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> :test_unit <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>features<span style="color: #000000; font-weight: bold;">/</span>support<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> :cucumber <span style="color: #7a0874; font-weight: bold;">&#125;</span>
end
&nbsp;
&nbsp;
guard <span style="color: #ff0000;">'rspec'</span>, :version =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000;">2</span>, :cli =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;--drb&quot;</span>, :all_on_start =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">false</span>, :all_after_pass =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">false</span> <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>^spec<span style="color: #000000; font-weight: bold;">/</span>.+_spec\.rb$<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>^lib<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.+<span style="color: #7a0874; font-weight: bold;">&#41;</span>\.rb$<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #000000; font-weight: bold;">|</span>m<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #ff0000;">&quot;spec/lib/#{m[1]}_spec.rb&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'spec/spec_helper.rb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #ff0000;">&quot;spec&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># Rails example</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>^app<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.+<span style="color: #7a0874; font-weight: bold;">&#41;</span>\.rb$<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                           <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #000000; font-weight: bold;">|</span>m<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #ff0000;">&quot;spec/#{m[1]}_spec.rb&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>^app<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>\.erb<span style="color: #000000; font-weight: bold;">|</span>\.haml<span style="color: #7a0874; font-weight: bold;">&#41;</span>$<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                 <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #000000; font-weight: bold;">|</span>m<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #ff0000;">&quot;spec/#{m[1]}#{m[2]}_spec.rb&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>^app<span style="color: #000000; font-weight: bold;">/</span>controllers<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.+<span style="color: #7a0874; font-weight: bold;">&#41;</span>_<span style="color: #7a0874; font-weight: bold;">&#40;</span>controller<span style="color: #7a0874; font-weight: bold;">&#41;</span>\.rb$<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #000000; font-weight: bold;">|</span>m<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;spec/routing/#{m[1]}_routing_spec.rb&quot;</span>, <span style="color: #ff0000;">&quot;spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb&quot;</span>, <span style="color: #ff0000;">&quot;spec/acceptance/#{m[1]}_spec.rb&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>^spec<span style="color: #000000; font-weight: bold;">/</span>support<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.+<span style="color: #7a0874; font-weight: bold;">&#41;</span>\.rb$<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                  <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #ff0000;">&quot;spec&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'config/routes.rb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                           <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #ff0000;">&quot;spec/routing&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'app/controllers/application_controller.rb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #ff0000;">&quot;spec/controllers&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #666666; font-style: italic;"># Capybara request specs</span>
  <span style="color: #c20cb9; font-weight: bold;">watch</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">%</span>r<span style="color: #7a0874; font-weight: bold;">&#123;</span>^app<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.+<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">*</span>\.<span style="color: #7a0874; font-weight: bold;">&#40;</span>erb<span style="color: #000000; font-weight: bold;">|</span>haml<span style="color: #7a0874; font-weight: bold;">&#41;</span>$<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>          <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #000000; font-weight: bold;">|</span>m<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #ff0000;">&quot;spec/requests/#{m[1]}_spec.rb&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
end</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2012/03/23/rails-3-2-1-rspec-and-capybara/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ExtJS 4 Themes</title>
		<link>http://www.skatercoder.com/2011/05/18/extjs-4-themes/</link>
		<comments>http://www.skatercoder.com/2011/05/18/extjs-4-themes/#comments</comments>
		<pubDate>Wed, 18 May 2011 06:34:25 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[ExtJS 4]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=499</guid>
		<description><![CDATA[Steps to customise your ExtJS Theme Install gem to generate css files from SASS 1 $ sudo gem install compass Copy the following the folders from the ExtJS SDK to your app&#8217;s folder / /resources/ /resources/css/ /resources/sass/ /resources/sass/config.rb /resources/images/ /resources/themes/ Edit config.rb and make sure the paths are correct Add your own .scss files in [...]]]></description>
			<content:encoded><![CDATA[<p>Steps to customise your ExtJS Theme</p>
<p>Install gem to generate css files from SASS</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: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> compass</pre></td></tr></table></div>

<p>Copy the following the folders from the ExtJS SDK to your app&#8217;s folder </p>
<p>/<br />
/resources/<br />
/resources/css/<br />
/resources/sass/<br />
/resources/sass/config.rb<br />
/resources/images/<br />
/resources/themes/</p>
<p>Edit config.rb and make sure the paths are correct<br />
Add your own .scss files in /resources/sass/</p>
<p>Generate css files</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;">$ compass compile resources<span style="color: #000000; font-weight: bold;">/</span>sass</pre></td></tr></table></div>

<p>References<br />
<a href="http://dev.sencha.com/deploy/ext-4.0.0/docs/guide/theming.html" target="_blank">http://dev.sencha.com/deploy/ext-4.0.0/docs/guide/theming.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2011/05/18/extjs-4-themes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging script/runner</title>
		<link>http://www.skatercoder.com/2011/03/21/debugging-scriptrunner/</link>
		<comments>http://www.skatercoder.com/2011/03/21/debugging-scriptrunner/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 12:12:58 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=494</guid>
		<description><![CDATA[If you need to debug script/runner 1 2 $ sudo gem install ruby-debug $ rdebug script/runner script.rb References http://cheat.errtheblog.com/s/rdebug/]]></description>
			<content:encoded><![CDATA[<p>If you need to debug script/runner</p>

<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;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> ruby-debug
$ rdebug script<span style="color: #000000; font-weight: bold;">/</span>runner script.rb</pre></td></tr></table></div>

<p>References<br />
<a href="http://cheat.errtheblog.com/s/rdebug/" target="_blank">http://cheat.errtheblog.com/s/rdebug/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2011/03/21/debugging-scriptrunner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eyes On Asia Website Launch</title>
		<link>http://www.skatercoder.com/2010/11/06/eyes-on-asia-website-launch/</link>
		<comments>http://www.skatercoder.com/2010/11/06/eyes-on-asia-website-launch/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 02:40:47 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Portfolio]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=474</guid>
		<description><![CDATA[Beautiful photos by Felix Hug, professional travel photographer from Switzerland residing in Singapore. Developed this website to showcase his photos, photography workshops and travel photography getaways. Visit his website at www.eyesonasia.net for more of his breath-taking photography.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.eyesonasia.net" target="_blank"><img src="/wp-content/uploads/2010/11/Screen-shot-2010-11-06-at-AM-10.31.43-600x576.jpg" alt="" title="Eyes On Asia" width="600" height="576" class="alignnone size-medium wp-image-475" /></a></p>
<p>Beautiful photos by Felix Hug, professional travel photographer from Switzerland residing in Singapore. Developed this website to showcase his photos, photography workshops and travel photography getaways. Visit his website at <a href="http://www.eyesonasia.net" target="_blank">www.eyesonasia.net</a> for more of his breath-taking photography.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/11/06/eyes-on-asia-website-launch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>dothebag.sg arrives in Singapore!</title>
		<link>http://www.skatercoder.com/2010/09/20/dothebag-sg-arrives-in-singapore/</link>
		<comments>http://www.skatercoder.com/2010/09/20/dothebag-sg-arrives-in-singapore/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 14:56:28 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Portfolio]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=465</guid>
		<description><![CDATA[Another website for the portfolio :) And if you like your bags minimalist in design, head on down to www.dothebag.sg]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dothebag.asia" target="_blank"><img src="http://www.skatercoder.com/wp-content/uploads/2010/09/dothebag-600x440.jpg" alt="" title="dothebag" width="600" height="440" class="alignnone size-medium wp-image-466" /></a></p>
<p>Another website for the portfolio :) And if you like your bags minimalist in design, head on down to <a href="http://www.dothebag.sg" target="_blank">www.dothebag.sg</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/09/20/dothebag-sg-arrives-in-singapore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Singapore Limousines Hire and Bus Charter</title>
		<link>http://www.skatercoder.com/2010/09/20/alliance-transportation-service-singapore-limousines-hire-and-bus-charter/</link>
		<comments>http://www.skatercoder.com/2010/09/20/alliance-transportation-service-singapore-limousines-hire-and-bus-charter/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 14:49:37 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Portfolio]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=461</guid>
		<description><![CDATA[Latest site launch featuring quality and economical transport services in Singapore View the site at www.alliancetransport.com.sg]]></description>
			<content:encoded><![CDATA[<p>Latest site launch featuring quality and economical transport services in Singapore</p>
<p><a href="http://www.singaporelimousines.com.sg"><img src="http://www.skatercoder.com/wp-content/uploads/2010/09/alliancetransport-600x580.jpg" alt="" title="alliancetransport" width="600" height="580" class="alignnone size-medium wp-image-462" border="0" /></a></p>
<p>View the site at <a href="http://www.alliancetransport.com.sg" target="_blank">www.alliancetransport.com.sg</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/09/20/alliance-transportation-service-singapore-limousines-hire-and-bus-charter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Spree with cucumber + spork + autotest + pickle + factory girl</title>
		<link>http://www.skatercoder.com/2010/09/04/testing-spree-with-cucumber-spork-autotest-pickle/</link>
		<comments>http://www.skatercoder.com/2010/09/04/testing-spree-with-cucumber-spork-autotest-pickle/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 13:10:22 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[autotest]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[factory girl]]></category>
		<category><![CDATA[pickle]]></category>
		<category><![CDATA[spork]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=439</guid>
		<description><![CDATA[Copy this from the spree root folder into your app 1 2 3 spree-0.11.0/features to yourapp/features Edit features/support/env.rb 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 30 31 32 33 34 35 36 37 [...]]]></description>
			<content:encoded><![CDATA[<p>Copy this from the spree root folder into your app</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">spree-0.11.0<span style="color: #000000; font-weight: bold;">/</span>features
to 
yourapp<span style="color: #000000; font-weight: bold;">/</span>features</pre></td></tr></table></div>

<p>Edit features/support/env.rb</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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;RAILS_ENV&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#996600;">&quot;cucumber&quot;</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'spork'</span>
&nbsp;
Spork.<span style="color:#9900CC;">prefork</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">expand_path</span><span style="color:#006600; font-weight:bold;">&#40;</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'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cucumber/formatter/unicode'</span> <span style="color:#008000; font-style:italic;"># Remove this line if you don't want Cucumber Unicode support</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cucumber/rails/world'</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cucumber/rails/active_record'</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cucumber/web/tableish'</span>
&nbsp;
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'capybara/rails'</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'capybara/cucumber'</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'capybara/session'</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cucumber/rails/capybara_javascript_emulation'</span> <span style="color:#008000; font-style:italic;"># Lets you click links with onclick javascript handlers without using @culerity or @javascript</span>
  <span style="color:#008000; font-style:italic;"># Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In</span>
  <span style="color:#008000; font-style:italic;"># order to ease the transition to Capybara we set the default here. If you'd</span>
  <span style="color:#008000; font-style:italic;"># prefer to use XPath just remove this line and adjust any selectors in your</span>
  <span style="color:#008000; font-style:italic;"># steps to use the XPath syntax.</span>
  Capybara.<span style="color:#9900CC;">default_selector</span> = <span style="color:#ff3333; font-weight:bold;">:css</span>
&nbsp;
&nbsp;
  <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">glob</span><span style="color:#006600; font-weight:bold;">&#40;</span>SPREE_ROOT <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/db/default/*.{yml,csv,rb}'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
    Fixtures.<span style="color:#9900CC;">create_fixtures</span><span style="color:#006600; font-weight:bold;">&#40;</span>SPREE_ROOT <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/db/default'</span>, <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">basename</span><span style="color:#006600; font-weight:bold;">&#40;</span>file, <span style="color:#996600;">'.*'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">glob</span><span style="color:#006600; font-weight:bold;">&#40;</span>SPREE_ROOT <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/test/fixtures/*.{yml,csv,rb}'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
    Fixtures.<span style="color:#9900CC;">create_fixtures</span><span style="color:#006600; font-weight:bold;">&#40;</span>SPREE_ROOT <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/test/fixtures'</span>, <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">basename</span><span style="color:#006600; font-weight:bold;">&#40;</span>file, <span style="color:#996600;">'.*'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'faker'</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'factory_girl'</span>
&nbsp;
  <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>SPREE_ROOT, <span style="color:#996600;">'test'</span>, <span style="color:#996600;">'factories'</span>, <span style="color:#996600;">'*.rb'</span><span style="color:#006600; font-weight:bold;">&#41;</span>,
    <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>RAILS_ROOT, <span style="color:#996600;">'vendor'</span>, <span style="color:#996600;">'extensions'</span>, <span style="color:#996600;">'*'</span>,
      <span style="color:#996600;">'{test,spec}'</span>, <span style="color:#996600;">'factories'</span>, <span style="color:#996600;">'*.rb'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>path<span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">glob</span><span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>factory<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC0066; font-weight:bold;">require</span> factory <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'factory_girl/step_definitions'</span>
&nbsp;
  Zone.<span style="color:#9900CC;">class_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">global</span>
      find_by_name<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;GlobalZone&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> Factory<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:global_zone</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>
&nbsp;
  Product.<span style="color:#9900CC;">class_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> taxon=<span style="color:#006600; font-weight:bold;">&#40;</span>taxon_name<span style="color:#006600; font-weight:bold;">&#41;</span>
      taxonomy = Taxonomy.<span style="color:#9900CC;">find_or_create_by_name</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Category&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      taxon = Taxon.<span style="color:#9900CC;">find_or_create_by_name_and_taxonomy_id</span><span style="color:#006600; font-weight:bold;">&#40;</span>taxon_name, taxonomy<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">taxons</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> taxon
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  ShippingMethod.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;UPS Ground&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:zone</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Zone.<span style="color:#9900CC;">global</span>, <span style="color:#ff3333; font-weight:bold;">:calculator</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#6666ff; font-weight:bold;">Calculator::FlatRate</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  coupon = Coupon.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:code</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;SPREE&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;$5 off any order&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:combine</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#ff3333; font-weight:bold;">:calculator</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#6666ff; font-weight:bold;">Calculator::FlatRate</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  coupon.<span style="color:#9900CC;">calculator</span>.<span style="color:#9900CC;">update_attribute</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:preferred_amount</span>, <span style="color:#006666;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
Spork.<span style="color:#9900CC;">each_run</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#008000; font-style:italic;"># If you set this to false, any error raised from within your app will bubble</span>
  <span style="color:#008000; font-style:italic;"># up to your step definition and out to cucumber unless you catch it somewhere</span>
  <span style="color:#008000; font-style:italic;"># on the way. You can make Rails rescue errors and render error pages on a</span>
  <span style="color:#008000; font-style:italic;"># per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;"># If you set this to true, Rails will rescue all errors and render error</span>
  <span style="color:#008000; font-style:italic;"># pages, more or less in the same way your application would behave in the</span>
  <span style="color:#008000; font-style:italic;"># default production environment. It's not recommended to do this for all</span>
  <span style="color:#008000; font-style:italic;"># of your scenarios, as this makes it hard to discover errors in your application.</span>
  <span style="color:#6666ff; font-weight:bold;">ActionController::Base</span>.<span style="color:#9900CC;">allow_rescue</span> = <span style="color:#0000FF; font-weight:bold;">false</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># If you set this to true, each scenario will run in a database transaction.</span>
  <span style="color:#008000; font-style:italic;"># You can still turn off transactions on a per-scenario basis, simply tagging</span>
  <span style="color:#008000; font-style:italic;"># a feature or scenario with the @no-txn tag. If you are using Capybara,</span>
  <span style="color:#008000; font-style:italic;"># tagging with @culerity or @javascript will also turn transactions off.</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;"># If you set this to false, transactions will be off for all scenarios,</span>
  <span style="color:#008000; font-style:italic;"># regardless of whether you use @no-txn or not.</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;"># Beware that turning transactions off will leave data in your database</span>
  <span style="color:#008000; font-style:italic;"># after each scenario, which can lead to hard-to-debug failures in</span>
  <span style="color:#008000; font-style:italic;"># subsequent scenarios. If you do this, we recommend you create a Before</span>
  <span style="color:#008000; font-style:italic;"># block that will explicitly put your database in a known state.</span>
  <span style="color:#6666ff; font-weight:bold;">Cucumber::Rails::World</span>.<span style="color:#9900CC;">use_transactional_fixtures</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># How to clean your database when transactions are turned off. See</span>
  <span style="color:#008000; font-style:italic;"># http://github.com/bmabey/database_cleaner for more info.</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'database_cleaner'</span>
  DatabaseCleaner.<span style="color:#9900CC;">strategy</span> = <span style="color:#ff3333; font-weight:bold;">:truncation</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>config/cucumber.yml</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;"><span style="color:#006600; font-weight:bold;">&lt;%</span>
rerun = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">file</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'rerun.txt'</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#CC00FF; font-weight:bold;">IO</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'rerun.txt'</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#996600;">&quot;&quot;</span>
rerun_opts = rerun.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">strip</span>.<span style="color:#9900CC;">empty</span>? ? <span style="color:#996600;">&quot;--format progress features&quot;</span> : <span style="color:#996600;">&quot;--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}&quot;</span>
std_opts = <span style="color:#996600;">&quot;#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip&quot;</span>
<span style="color:#006600; font-weight:bold;">%&gt;</span>
default: --drb <span style="color:#006600; font-weight:bold;">&lt;%</span>= std_opts <span style="color:#006600; font-weight:bold;">%&gt;</span>
wip: --drb --tags @wip:3 --wip features
autotest: --drb features --guess --format 'pretty' --color
autotest-all: --drb features --guess --format 'progress' --color</pre></td></tr></table></div>

<p>config/environments/cucumber.rb</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'AUTOFEATURE'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;true&quot;</span>
ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'RSPEC'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;true&quot;</span></pre></td></tr></table></div>

<p>config/database.yml</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">cucumber:
  <span style="color:#006600; font-weight:bold;">&lt;&lt;</span>: <span style="color:#006600; font-weight:bold;">*</span>test</pre></td></tr></table></div>

<p>Run your tests!</p>

<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;">$ spork cuc
$ autotest</pre></td></tr></table></div>

<h2>Resources</h2>
<p><a href="http://groups.google.com/group/spree-user/browse_thread/thread/81b006af48d3166d">http://groups.google.com/group/spree-user/browse_thread/thread/81b006af48d3166d</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/09/04/testing-spree-with-cucumber-spork-autotest-pickle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>How to upload multiple files on rails (uploadify + paperclip + jquery)</title>
		<link>http://www.skatercoder.com/2010/08/31/how-to-upload-multiple-files-on-rails-uploadify-paperclip-jquery/</link>
		<comments>http://www.skatercoder.com/2010/08/31/how-to-upload-multiple-files-on-rails-uploadify-paperclip-jquery/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 04:27:50 +0000</pubDate>
		<dc:creator>roadburn</dc:creator>
				<category><![CDATA[Coding Tips]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[multiple files upload]]></category>
		<category><![CDATA[paperclip]]></category>
		<category><![CDATA[uploadify]]></category>

		<guid isPermaLink="false">http://www.skatercoder.com/?p=397</guid>
		<description><![CDATA[Setting Up Download Uploadify from http://www.uploadify.com/ copy the uploadify files into the following directories 1 2 3 4 5 6 7 public/javascripts/uploadify/jquery.uploadify-2.1.0.min.js public/javascripts/uploadify/uploadify.swf public/javascripts/uploadify/swfobject.js &#160; public/images/cancel.png &#160; public/stylesheets/uploadify.css Create this file app/middleware/flash_session_cookie_middleware.rb 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 require 'rack/utils' class FlashSessionCookieMiddleware def initialize&#40;app, session_key = [...]]]></description>
			<content:encoded><![CDATA[<h2>Setting Up</h2>
<p>Download Uploadify from<br />
<a href="http://www.uploadify.com/">http://www.uploadify.com/</a></p>
<p>copy the uploadify files into the following directories</p>

<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;">public<span style="color: #000000; font-weight: bold;">/</span>javascripts<span style="color: #000000; font-weight: bold;">/</span>uploadify<span style="color: #000000; font-weight: bold;">/</span>jquery.uploadify-2.1.0.min.js
public<span style="color: #000000; font-weight: bold;">/</span>javascripts<span style="color: #000000; font-weight: bold;">/</span>uploadify<span style="color: #000000; font-weight: bold;">/</span>uploadify.swf
public<span style="color: #000000; font-weight: bold;">/</span>javascripts<span style="color: #000000; font-weight: bold;">/</span>uploadify<span style="color: #000000; font-weight: bold;">/</span>swfobject.js
&nbsp;
public<span style="color: #000000; font-weight: bold;">/</span>images<span style="color: #000000; font-weight: bold;">/</span>cancel.png
&nbsp;
public<span style="color: #000000; font-weight: bold;">/</span>stylesheets<span style="color: #000000; font-weight: bold;">/</span>uploadify.css</pre></td></tr></table></div>

<p>Create this file<br />
<strong>app/middleware/flash_session_cookie_middleware.rb</strong></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
</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;">'rack/utils'</span> 
<span style="color:#9966CC; font-weight:bold;">class</span> FlashSessionCookieMiddleware 
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>app, session_key = <span style="color:#996600;">'_session_id'</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
    <span style="color:#0066ff; font-weight:bold;">@app</span> = app 
    <span style="color:#0066ff; font-weight:bold;">@session_key</span> = session_key 
  <span style="color:#9966CC; font-weight:bold;">end</span> 
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> call<span style="color:#006600; font-weight:bold;">&#40;</span>env<span style="color:#006600; font-weight:bold;">&#41;</span> 
    <span style="color:#9966CC; font-weight:bold;">if</span> env<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'HTTP_USER_AGENT'</span><span style="color:#006600; font-weight:bold;">&#93;</span> =~ <span style="color:#006600; font-weight:bold;">/</span>^<span style="color:#006600; font-weight:bold;">&#40;</span>Adobe<span style="color:#006600; font-weight:bold;">|</span>Shockwave<span style="color:#006600; font-weight:bold;">&#41;</span> Flash<span style="color:#006600; font-weight:bold;">/</span> 
      req = <span style="color:#6666ff; font-weight:bold;">Rack::Request</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>env<span style="color:#006600; font-weight:bold;">&#41;</span> 
      env<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'HTTP_COOKIE'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;#{@session_key}=#{req.params[@session_key]}&quot;</span>.<span style="color:#9900CC;">freeze</span> <span style="color:#9966CC; font-weight:bold;">unless</span> req.<span style="color:#9900CC;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span>@session_key<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>? 
    <span style="color:#9966CC; font-weight:bold;">end</span> 
    <span style="color:#0066ff; font-weight:bold;">@app</span>.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>env<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></td></tr></table></div>

<p>Add this line to<br />
<strong>config/initializers/session_store.rb</strong></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:#6666ff; font-weight:bold;">ActionController::Dispatcher</span>.<span style="color:#9900CC;">middleware</span>.<span style="color:#9900CC;">insert_before</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#6666ff; font-weight:bold;">ActionController::Base</span>.<span style="color:#9900CC;">session_store</span>, FlashSessionCookieMiddleware, <span style="color:#6666ff; font-weight:bold;">ActionController::Base</span>.<span style="color:#9900CC;">session_options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:key</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>Make sure your environment.rb file has this</p>
<p><strong>config/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;"><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>
&nbsp;
  config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">'mime-types'</span>, <span style="color:#ff3333; font-weight:bold;">:lib</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'mime/types'</span>
  config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">'paperclip'</span> 
&nbsp;
  <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>middleware<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>dir<span style="color:#006600; font-weight:bold;">|</span> 
    config.<span style="color:#9900CC;">load_paths</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;#{RAILS_ROOT}/app/#{dir}&quot;</span> 
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<h2>Models</h2>
<p>Let&#8217;s assume you want to create a photo album with many photos.</p>
<p>Create your photo model with the following:</p>
<p><strong>db/migrate/create_photos.rb</strong></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
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> CreatePhotos <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;">:photos</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:#CC0066; font-weight:bold;">integer</span> <span style="color:#ff3333; font-weight:bold;">:attachable_id</span>
      t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#ff3333; font-weight:bold;">:description</span>  
      t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#ff3333; font-weight:bold;">:data_file_name</span>  
      t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#ff3333; font-weight:bold;">:data_content_type</span>  
      t.<span style="color:#CC0066; font-weight:bold;">integer</span> <span style="color:#ff3333; font-weight:bold;">:data_file_size</span>  
      t.<span style="color:#9900CC;">datetime</span> <span style="color:#ff3333; font-weight:bold;">:data_updated_at</span>
      t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#ff3333; font-weight:bold;">:parent</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;">:images</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>In your album model:</p>
<p><strong>app/model/album.rb</strong></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;">has_many <span style="color:#ff3333; font-weight:bold;">:photos</span>, <span style="color:#ff3333; font-weight:bold;">:dependent</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:destroy</span>, <span style="color:#ff3333; font-weight:bold;">:foreign_key</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:attachable_id</span></pre></td></tr></table></div>

<p>In your photo model:<br />
<strong>app/model/photo.rb</strong></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
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">belongs_to <span style="color:#ff3333; font-weight:bold;">:album</span>, <span style="color:#ff3333; font-weight:bold;">:foreign_key</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:attachable_id</span>
&nbsp;
has_attached_file <span style="color:#ff3333; font-weight:bold;">:data</span>, 
      <span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/assets/images/:id/:style/:basename.:extension&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:path</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;:rails_root/public/assets/images/:id/:style/:basename.:extension&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:styles</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;">:large</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;800x800&gt;&quot;</span>, 
      <span style="color:#ff3333; font-weight:bold;">:medium</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;300x300&gt;&quot;</span>, 
      <span style="color:#ff3333; font-weight:bold;">:thumb</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;100x100#&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
validates_attachment_presence <span style="color:#ff3333; font-weight:bold;">:data</span>
validates_attachment_size <span style="color:#ff3333; font-weight:bold;">:data</span>, <span style="color:#ff3333; font-weight:bold;">:less_than</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">2</span>.<span style="color:#9900CC;">megabytes</span>  
validates_attachment_content_type <span style="color:#ff3333; font-weight:bold;">:data</span>, <span style="color:#ff3333; font-weight:bold;">:content_type</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'image/jpeg'</span>, <span style="color:#996600;">'image/jpg'</span>, <span style="color:#996600;">'image/png'</span>, <span style="color:#996600;">'image/gif'</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></td></tr></table></div>

<h2>Controllers</h2>
<p><strong>app/controllers/photos_controller.rb</strong></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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> PhotosController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController 
  <span style="color:#9966CC; font-weight:bold;">def</span> create
&nbsp;
    newparams = coerce<span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#41;</span> 
    <span style="color:#0066ff; font-weight:bold;">@photo</span> = Photo.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>newparams<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:upload</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
    <span style="color:#006600; font-weight:bold;">//</span> so this photo can belong to other models other than album
    <span style="color:#0066ff; font-weight:bold;">@parent</span> = <span style="color:#0066ff; font-weight:bold;">@photo</span>.<span style="color:#9900CC;">parent</span>.<span style="color:#9900CC;">constantize</span>.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>@photo.<span style="color:#9900CC;">attachable_id</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@photo</span>.<span style="color:#9900CC;">save</span>
      flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Successfully uploaded photo.&quot;</span>
      respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>format<span style="color:#006600; font-weight:bold;">|</span> 
        <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#006600; font-weight:bold;">&#123;</span>redirect_to <span style="color:#0066ff; font-weight:bold;">@parent</span><span style="color:#006600; font-weight:bold;">&#125;</span> 
        <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">json</span>  <span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:json</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;">:result</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'success'</span>, <span style="color:#ff3333; font-weight:bold;">:upload</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> photo_path<span style="color:#006600; font-weight:bold;">&#40;</span>@photo<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> 
      <span style="color:#9966CC; font-weight:bold;">end</span> 
    <span style="color:#9966CC; font-weight:bold;">else</span>
      flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Only gif, jpg or png files allowed&quot;</span>
      respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>format<span style="color:#006600; font-weight:bold;">|</span> 
        <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#006600; font-weight:bold;">&#123;</span>redirect_to <span style="color:#0066ff; font-weight:bold;">@parent</span><span style="color:#006600; font-weight:bold;">&#125;</span> 
        <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">json</span>  <span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:json</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;">:result</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'failed'</span><span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</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;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> show
    <span style="color:#0066ff; font-weight:bold;">@photo</span> = Photo.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</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>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> coerce<span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#41;</span> 
    <span style="color:#9966CC; font-weight:bold;">if</span> params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:upload</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>? 
      h = <span style="color:#CC00FF; font-weight:bold;">Hash</span>.<span style="color:#9900CC;">new</span> 
      h<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:upload</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#CC00FF; font-weight:bold;">Hash</span>.<span style="color:#9900CC;">new</span> 
      h<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:upload</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:attachable_id</span><span style="color:#006600; font-weight:bold;">&#93;</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:attachable_id</span><span style="color:#006600; font-weight:bold;">&#93;</span> 
      h<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:upload</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:parent</span><span style="color:#006600; font-weight:bold;">&#93;</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:parent</span><span style="color:#006600; font-weight:bold;">&#93;</span> 
      h<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:upload</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:data</span><span style="color:#006600; font-weight:bold;">&#93;</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Filedata</span><span style="color:#006600; font-weight:bold;">&#93;</span> 
      h<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:upload</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:data</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">content_type</span> =  <span style="color:#6666ff; font-weight:bold;">MIME::Types</span>.<span style="color:#9900CC;">type_for</span><span style="color:#006600; font-weight:bold;">&#40;</span>h<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:upload</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:data</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">original_filename</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_s</span> 
      h 
    <span style="color:#9966CC; font-weight:bold;">else</span> 
      params 
    <span style="color:#9966CC; font-weight:bold;">end</span> 
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<h2>Views</h2>
<p><strong>app/views/albums/show.html.erb</strong></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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= stylesheet_link_tag <span style="color:#996600;">&quot;uploadify&quot;</span>  <span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span>= javascript_include_tag <span style="color:#996600;">&quot;uploadify/swfobject&quot;</span>, <span style="color:#996600;">&quot;uploadify/jquery.uploadify.v2.1.0.min.js&quot;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
<span style="color:#006600; font-weight:bold;">&lt;%-</span> session_key_name = <span style="color:#6666ff; font-weight:bold;">ActionController::Base</span>.<span style="color:#9900CC;">session_options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:key</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">-%&gt;</span>
&nbsp;
&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt; 
jQuery.noConflict();
&nbsp;
jQuery().ready(function() { 
   jQuery('#photo_upload').click(function(event){ 
      event.preventDefault(); 
   }); 
&nbsp;
  jQuery('#photo_upload').uploadify({ 
&nbsp;
    'uploader'    : '/javascripts/uploadify/uploadify.swf', 
    'script'      : '/cms/photos', 
    'multi'       : true, 
    'cancelImg' : '/photos/cancel.png',
&nbsp;
    onComplete : function(event, queueID, fileObj, response, data) { 
	var dat = eval('(' + response + ')'); 
	if (dat.result=='success'){
 	  jQuery.getScript(dat.upload);
        }else{
	  alert(&quot;Only .jpg, .gif, .png files under 2MB allowed. &quot;)
	}
    }, 
&nbsp;
    'scriptData' : { 'format' : 'json', 
      '<span style="color:#006600; font-weight:bold;">&lt;%</span>= session_key_name <span style="color:#006600; font-weight:bold;">%&gt;</span>' : encodeURIComponent('<span style="color:#006600; font-weight:bold;">&lt;%</span>= u cookies<span style="color:#006600; font-weight:bold;">&#91;</span>session_key_name<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>'), 
      'authenticity_token' : encodeURIComponent('<span style="color:#006600; font-weight:bold;">&lt;%</span>= u form_authenticity_token <span style="color:#9966CC; font-weight:bold;">if</span> protect_against_forgery? <span style="color:#006600; font-weight:bold;">%&gt;</span>'), 
      'attachable_id' 	: '<span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#0066ff; font-weight:bold;">@album</span>.<span style="color:#9900CC;">id</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>',
      'parent' 	: 'Album'} 
    }); 
    jQuery('#photo_submit').click(function(event){ 
      event.preventDefault(); 
      jQuery('#photo_upload').uploadifyUpload(); 
    }); 
  }); 
&lt;/script&gt;
&nbsp;
<span style="color:#006600; font-weight:bold;">&lt;%</span> form_for Image.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:attachable_id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@deal</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:html</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;">:multipart</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> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
	&lt;div class=&quot;image-uploader&quot;&gt;
		<span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">file_field</span> <span style="color:#ff3333; font-weight:bold;">:data</span>, <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'image_upload'</span>  <span style="color:#006600; font-weight:bold;">%&gt;</span>
		<span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">submit</span> <span style="color:#996600;">&quot;Upload Images&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'image_submit'</span><span style="color:#006600; font-weight:bold;">%&gt;</span>
	&lt;/div&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></pre></td></tr></table></div>

<h2>Resources</h2>
<p>Many thanks to the following articles that helped me figure out how to get this working<br />
Please follow the links for more detailed explanations</p>
<p><a href="http://fencore.posterous.com/uploadify-with-paperclip-on-rails-tutorial" target="_blank">http://fencore.posterous.com/uploadify-with-paperclip-on-rails-tutorial</a><br />
<a href="http://timmyc.posterous.com/uploadify-on-rails-with-paperclip" target="_blank">http://timmyc.posterous.com/uploadify-on-rails-with-paperclip</a><br />
<a href="http://www.practicalecommerce.com/blogs/post/432-Multiple-Attachments-in-Rails" target="_blank">http://www.practicalecommerce.com/blogs/post/432-Multiple-Attachments-in-Rails</a><br />
<a href="http://www.utoronto.ca/web/htmldocs/book/book-3ed/appb/mimetype.html" target="_blank">http://www.utoronto.ca/web/htmldocs/book/book-3ed/appb/mimetype.html</a><br />
<a href="http://en.wikipedia.org/wiki/Internet_media_type" target="_blank">http://en.wikipedia.org/wiki/Internet_media_type</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skatercoder.com/2010/08/31/how-to-upload-multiple-files-on-rails-uploadify-paperclip-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

