<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Chee's blog &#187; Ruby</title>
	<atom:link href="http://cheeyeo.wordpress.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://cheeyeo.wordpress.com</link>
	<description>Observations, tips, tricks, articles on Ruby and anything else that follows.</description>
	<lastBuildDate>Wed, 18 Mar 2009 00:19:55 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='cheeyeo.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/1c59aee0b01111d834f3bfb3e82f9b0d?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Chee's blog &#187; Ruby</title>
		<link>http://cheeyeo.wordpress.com</link>
	</image>
			<item>
		<title>FIX RVIDEO 0.9.4 &#8216;NIL&#8217; BUG</title>
		<link>http://cheeyeo.wordpress.com/2009/03/18/fix-rvideo-094-nil-bug/</link>
		<comments>http://cheeyeo.wordpress.com/2009/03/18/fix-rvideo-094-nil-bug/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 00:19:55 +0000</pubDate>
		<dc:creator>cheeyeo</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[rvideo]]></category>

		<guid isPermaLink="false">http://cheeyeo.wordpress.com/?p=61</guid>
		<description><![CDATA[RVideo bug on latest version of ffmpeg<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=61&subd=cheeyeo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I use RVideo gem a lot for a video processing application I have been building in Rails which will be open sourced soon on github. Using the gem you can create a RVideo::Inspector object to gather information about the uploaded file including its fps and content type.</p>
<p>If you use the latest version of ffmpeg (mine is SVN-r16905), I find that I keep getting nil values whenever I run the inspector objects. I googled around and found that this is due to a regular expression mismatch in the source. Change line 53 in inspector.rb in the source to:</p>
<pre>metadata = /(Input \#.*)\n(Must|At\sleast)/m.match(@raw_response)
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cheeyeo.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cheeyeo.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cheeyeo.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cheeyeo.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cheeyeo.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cheeyeo.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cheeyeo.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cheeyeo.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cheeyeo.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cheeyeo.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=61&subd=cheeyeo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cheeyeo.wordpress.com/2009/03/18/fix-rvideo-094-nil-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">cheeyeo</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing attachment_fu undefined method error</title>
		<link>http://cheeyeo.wordpress.com/2009/02/19/fixing-attachment_fu-undefined-method-error/</link>
		<comments>http://cheeyeo.wordpress.com/2009/02/19/fixing-attachment_fu-undefined-method-error/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 22:36:24 +0000</pubDate>
		<dc:creator>cheeyeo</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[attachment_fu]]></category>
		<category><![CDATA[error]]></category>

		<guid isPermaLink="false">http://cheeyeo.wordpress.com/?p=47</guid>
		<description><![CDATA[How to fix undefined method error with using the attachment_fu plugin on Ruby 1.8.7<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=47&subd=cheeyeo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Hello there. First of all apologies for not posting for a while. I have been busy working on commercial Rails projects for the very first time and as such, that takes precedence. However, I am also aware of the need to keep blogging and keep up the practise more as a note to myself about the things I have encountered through work and also to show potential exmployers that I KNOW WHAT I AM TALKING ABOUT.</p>
<p>To start off 2009, I would like to highlight an interesting error I came across today with regards to using attachment_fu plugin. It is a great plugin for handling file uploads in Rails and there are plenty of resources on the web to get you started. The issue arose when I fired up an old Rails application running on 2.0.2 with a view that uses attachment_fu for uplaods. The following error appears on the console:</p>
<p><strong>NoMethodError in XXXController<br />
</strong></p>
<p><strong>undefined method `[]&#8216; for #&lt;Enumerable::Enumerator&#8230;&#8230;..&gt; </strong></p>
<p>So I upgraded to Rails 2.1 and 2.2 but the error still persisted. It transpired that it is a conflict with the verion of Ruby you have running on your system (I use a MAC running on Ruby 1.8.7.) &#8211; it appears to be an issue with Ruby 1.8.7 &#8217;s string methods mdofications.</p>
<p>To fix it simply navigate to vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb and change the following line:</p>
<p><strong><br />
</strong></p>
<p><strong>attachment_options[:path_prefix]   = attachment_options[:path_prefix]<br />
[1..-1] if options[:path_prefix].starts_with?(&#8216;/&#8217;) </strong></p>
<p>Note that starts_with? is a String method only in 1.8.7. Save an relaunch yor application and all should be well.</p>
<p>I obtained the above from the following google group link:</p>
<p>http://groups.google.com/group/attachment_fu/browse_thread/thread/502dd4504a59c84d</p>
<p>Hope this helps someone &#8211; certainly helps me after hours of debugging!</p>
<p>P/S if the above has changed since then please let me know as I may not be the most up to date.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cheeyeo.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cheeyeo.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cheeyeo.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cheeyeo.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cheeyeo.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cheeyeo.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cheeyeo.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cheeyeo.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cheeyeo.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cheeyeo.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=47&subd=cheeyeo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cheeyeo.wordpress.com/2009/02/19/fixing-attachment_fu-undefined-method-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">cheeyeo</media:title>
		</media:content>
	</item>
		<item>
		<title>FIXING NAMESPACE NOT FOUND ERROR ON MERB</title>
		<link>http://cheeyeo.wordpress.com/2008/09/26/fixing-namespace-not-found-error-on-merb/</link>
		<comments>http://cheeyeo.wordpress.com/2008/09/26/fixing-namespace-not-found-error-on-merb/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 11:13:48 +0000</pubDate>
		<dc:creator>cheeyeo</dc:creator>
				<category><![CDATA[Merb]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://cheeyeo.wordpress.com/?p=40</guid>
		<description><![CDATA[If you have just completed an application, its more than likely you would like to have an admin portal to administer users. The easiest way to do this in Merb is to use the &#8216;merb-gen resource_controller&#8217; command in your application directory to generate a CRUD controller and views for the resource. This is similar to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=40&subd=cheeyeo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>If you have just completed an application, its more than likely you would like to have an admin portal to administer users. The easiest way to do this in Merb is to use the <strong>&#8216;merb-gen resource_controller&#8217;</strong> command in your application directory to generate a CRUD controller and views for the resource. This is similar to using scaffold in rails.</p>
<p>Say for instance I have a resource called Posts and I want to generate an admin front-end to it. All I need to do is change to the application directory and type:</p>
<p>merb-gen resource_controller admin/posts</p>
<p>This creates a subfolder called &#8216;admin&#8217; within your controllers and a new posts controller within that to handle all the CRUD functions. However, on MERB 0.9.5, the controller is missing the module keyword and if you try to run the above you would receive a namespace or controller not found error.</p>
<p>To fix this, open up &#8216;admin/posts&#8217; controller and add &#8216;module Admin&#8217; to the file:</p>
<pre style="text-align:left;"><strong><span style="color:#800000;">module Admin

class Posts &lt; Application

....

end

end</span></strong></pre>
<p>Next add the required namespace to the &#8216;config/router.rb&#8217; file:</p>
<pre><strong><span style="color:#800000;">Merb::Router.prepare do |r|

r.namespace :admin do |admin|

admin.resources :posts

end

end</span></strong></pre>
<p>Fire up your app and it should all work. I&#8217;m not certain if this is fixed in subsequent versions of Merb but I did notice a ticket has been submitted for nested namespaces error. If anyone reading this has more information on the official line, please do leave a comment</p>
<p>NEWS FLASH:</p>
<p>Just received an up-to-date comment from one of the MERB framework developers who read this post and confirmed that the latest version of &#8216;merb-gen&#8217; has been fixed to prevent the error above. So upgrade your version of Merb to prevent it. And you still have to add in the namespace in your router file manually.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cheeyeo.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cheeyeo.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cheeyeo.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cheeyeo.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cheeyeo.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cheeyeo.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cheeyeo.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cheeyeo.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cheeyeo.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cheeyeo.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=40&subd=cheeyeo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cheeyeo.wordpress.com/2008/09/26/fixing-namespace-not-found-error-on-merb/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">cheeyeo</media:title>
		</media:content>
	</item>
		<item>
		<title>Parsing RSS feed using Ruby</title>
		<link>http://cheeyeo.wordpress.com/2008/08/20/parsing-rss-feed-using-ruby/</link>
		<comments>http://cheeyeo.wordpress.com/2008/08/20/parsing-rss-feed-using-ruby/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 14:31:52 +0000</pubDate>
		<dc:creator>cheeyeo</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://cheeyeo.wordpress.com/?p=23</guid>
		<description><![CDATA[Parsing rss feed using Ruby<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=23&subd=cheeyeo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of the commercial websites I implemented (www.bauhaus-bathrooms.co.uk) has a RSS feed for their news items. I have considered various alternatives for parsing the feed but nothing is more elegant and efficient than using Ruby. Here is an example snippet of it:</p>
<pre>
<strong>
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'

source = "http://www.bauhaus-bathrooms.co.uk/news/rss.xml"
content=""

open(source) do |s|
  content = s.read
end

rss = RSS::Parser.parse(content,false)

puts "Root values"
print "RSS title: ", rss.channel.title, "\n"
print "RSS link: ", rss.channel.link, "\n"
print "RSS description: ", rss.channel.description, "\n"
print "RSS publication date: ", rss.channel.date, "\n"

puts "Item values"
print "number of items: ", rss.items.size, "\n"
print "title of first item: ", rss.items[0].title, "\n"
print "link of first item: ", rss.items[0].link, "\n"
print "description of first items: ", rss.items[0].description, "\n"
print "date of first items: ", rss.items[0].date, "\n"

</strong>
</pre>
<p>Run the above on the command prompt and it should print out the requested properties of the feed.</p>
<p>It would be really good to be able to build a GUI interface using SHOES to display the feed contents. Might use that as a future project!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cheeyeo.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cheeyeo.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cheeyeo.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cheeyeo.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cheeyeo.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cheeyeo.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cheeyeo.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cheeyeo.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cheeyeo.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cheeyeo.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cheeyeo.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cheeyeo.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=23&subd=cheeyeo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cheeyeo.wordpress.com/2008/08/20/parsing-rss-feed-using-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">cheeyeo</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Rack</title>
		<link>http://cheeyeo.wordpress.com/2008/08/20/using-rack/</link>
		<comments>http://cheeyeo.wordpress.com/2008/08/20/using-rack/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 14:07:40 +0000</pubDate>
		<dc:creator>cheeyeo</dc:creator>
				<category><![CDATA[Merb]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://cheeyeo.wordpress.com/?p=15</guid>
		<description><![CDATA[I heve been experimenting with Rack for a while and thought I would write a short post about it here.
In essence, Rack is an API that sits between your web framework and the webserver itself. A basic Rack application consists of a call method that takes a hash of environmen variabes such as whre the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=15&subd=cheeyeo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I heve been experimenting with Rack for a while and thought I would write a short post about it here.</p>
<p>In essence, Rack is an API that sits between your web framework and the webserver itself. A basic Rack application consists of a call method that takes a hash of environmen variabes such as whre the request comes from and returns a hash of variables containing a status code, content-type and a response string.</p>
<p>A minimal Rack application is listed below:</p>
<pre>  <strong>%w(rubygems rack).each {|dep| require dep}

  app = lambda{|env| [200, {}, 'Another Test!']}

  Rack::Handler::Mongrel.run(app, <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ort=&gt; 3000)</strong></pre>
<p>Make sure the Rack gem in installed onto your local system first. Fire up the console and run the script.</p>
<p>You will see a flashing command prompt as the script is waiting to receive a HTTP request. Type &#8216;http://localhost:3000/&#8217; into your browser an you should see the string &#8216;Another Test&#8217; being returned to the browser.</p>
<p>I utilised the technique above to create a middleware class in my ongoing Merb application to handle file uploads away from the framework itself but stilll being able to access certain components of the framework (i.e. ActiveRecord objects) if needs to. An example of how to accomplish this can be found on <em><a href="http://brainspl.at/articles/2008/02/16/so-merb-core-is-built-on-rack-you-say-why-should-i-care" target="blank">Ezra&#8217;s blog(the creator of Merb)</a>.</em></p>
<p>A snippet of the middleware code will be made available soon after refactoring.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cheeyeo.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cheeyeo.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cheeyeo.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cheeyeo.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cheeyeo.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cheeyeo.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cheeyeo.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cheeyeo.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cheeyeo.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cheeyeo.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cheeyeo.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cheeyeo.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=15&subd=cheeyeo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cheeyeo.wordpress.com/2008/08/20/using-rack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">cheeyeo</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing file upload error using MERB on Windows</title>
		<link>http://cheeyeo.wordpress.com/2008/06/09/hello-world/</link>
		<comments>http://cheeyeo.wordpress.com/2008/06/09/hello-world/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 16:03:20 +0000</pubDate>
		<dc:creator>cheeyeo</dc:creator>
				<category><![CDATA[Merb]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I have just started experimenting with the MERB framework recently after using Rails for about a year. Although I am of the opinion that there are far too many web frameworks out there and I&#8217;m still in the process of learning Ruby properly as a language, I can&#8217;t help but be curious about the features [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=1&subd=cheeyeo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have just started experimenting with the MERB framework recently after using Rails for about a year. Although I am of the opinion that there are far too many web frameworks out there and I&#8217;m still in the process of learning Ruby properly as a language, I can&#8217;t help but be curious about the features this much-talked about framework can deliver.</p>
<p>I use a Windows box for development work in the offices. After a few failed attempts to get the gems to install correctly, I setup a simple file uploading script using just a controller as follows:</p>
<p><strong><br />
class Uploader &lt; Application<br />
  &nbsp;&nbsp;def index<br />
    &nbsp;&nbsp;&nbsp;&nbsp;render<br />
  &nbsp;&nbsp;end</p>
<p>  &nbsp;&nbsp;def upload<br />
     &nbsp;&nbsp;&nbsp;&nbsp;FileUtils.mv params[:file][:tempfile].path, Merb.root+&#8221;/uploads/#{params[:file][:filename]}&#8221;</p>
<p>    &nbsp;&nbsp;&nbsp;&nbsp;redirect &#8220;/uploader&#8221;<br />
  end</p>
<p>end<br />
</strong></p>
<p>The controller is uploading a file into the &#8216;uploads&#8217; directory in the application path. However, if you run the above as it is on a windows machine, you would receive a <strong>&#8216;permission denied&#8217;</strong> error. Changing the permissions on the folders would not make any difference.</p>
<p>The only way to fix this is to add a line of code to the gem library as follows:</p>
<ol>
<li>On your windows box, browse to you gem directory and locate &#8216;merb-core-&lt;version&gt;/lib/merb-core/dispatch/request.rb&#8217;.</li>
<li>Browse to line 526 and add the following:
<p>       <code>  else<br />
            data = body<br />
          end (approx line 526 here)<br />
</code><br />
           (only add the body.close line after end on line 526)</p>
<blockquote><p><strong> body.close</strong></p></blockquote>
</li>
</ol>
<p>Save the file. Restart your application and you should find that the controller is able to upload to the specified directory.</p>
<p>Official documentation on this can be found <a href="http://merb.devjavu.com/ticket/440">here</a>.</p>
<p>Although the bug has been found since January this year, I hope that anyone who comes across this problem on Windows will find this useful.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/cheeyeo.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/cheeyeo.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cheeyeo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cheeyeo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cheeyeo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cheeyeo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cheeyeo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cheeyeo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cheeyeo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cheeyeo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cheeyeo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cheeyeo.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cheeyeo.wordpress.com&blog=3937360&post=1&subd=cheeyeo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://cheeyeo.wordpress.com/2008/06/09/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">cheeyeo</media:title>
		</media:content>
	</item>
	</channel>
</rss>