<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DEQCSHo_fip7ImA9WhRRFE4.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131</id><updated>2011-11-28T04:26:09.446+05:00</updated><category term="exceptions" /><category term="Ruby" /><category term="cms" /><category term="Merb" /><category term="mongrel" /><category term="Rails" /><category term="ActiveResource" /><category term="Deployment" /><category term="Sequel" /><category term="https" /><category term="TinyMCE" /><category term="svn capistrano" /><category term="testing" /><category term="plugins" /><category term="capistrano" /><category term="hpricot" /><category term="svn" /><category term="railserb templates" /><title>Pakistani.rb</title><subtitle type="html">The blog of pakistan's foremost rubyist</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://hasham2.blogspot.com/" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Pakistanirb" /><feedburner:info uri="pakistanirb" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DE4EQXczcSp7ImA9Wx9UE08.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-9104205725698679845</id><published>2011-02-10T13:35:00.000+05:00</published><updated>2011-02-10T13:35:00.989+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-10T13:35:00.989+05:00</app:edited><title>Setup Ruby on Rails 3 for development on Ubuntu 10.10 aka Maverick Meerkat</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Installation on Ruby on Rails 3 on Ubuntu 10.10 is really easy peasy, However Ruby doesn't come pre-installed on Ubuntu like Python and Perl. To start of with installation of development tools for Rails we first need to install basic build tools like Compilers collection etc. There is handy packaged pre-built for that in Canonical repositories:&lt;br /&gt;
&lt;/div&gt;&lt;script src="https://gist.github.com/820118.js"&gt; &lt;/script&gt;&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Assuming you want to use My SQL server with Rails next we would need to setup Ruby, My SQL Server and Client as well as some other essential tools:&lt;br /&gt;
&lt;/div&gt;&lt;script src="https://gist.github.com/820126.js"&gt; &lt;/script&gt;&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Now that Ruby and My SQL is setup We need to pull the latest version of Rubygems at run setup as a super user:&lt;br /&gt;
&lt;/div&gt;&lt;script src="https://gist.github.com/820134.js"&gt; &lt;/script&gt;&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;In case you want to Sqlite 3 as development database with Rails 3 you may want to install that as well:&lt;br /&gt;
&lt;/div&gt;&lt;script src="https://gist.github.com/820135.js"&gt; &lt;/script&gt;&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;As a last step install latest version on Ruby on Rails framework gems:&lt;br /&gt;
&lt;/div&gt;&lt;script src="https://gist.github.com/820136.js"&gt; &lt;/script&gt;&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Now Ruby on Rails 3 is setup on your machine you can proceed with creating a new project and pulling in all the dependencies with bundler.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-9104205725698679845?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kTYHn8rdn8d6S3h62laBIw_N6EU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kTYHn8rdn8d6S3h62laBIw_N6EU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kTYHn8rdn8d6S3h62laBIw_N6EU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kTYHn8rdn8d6S3h62laBIw_N6EU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/XizTCTwFjos" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/9104205725698679845/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=9104205725698679845" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/9104205725698679845?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/9104205725698679845?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/XizTCTwFjos/setup-ruby-on-rails-3-for-development.html" title="Setup Ruby on Rails 3 for development on Ubuntu 10.10 aka Maverick Meerkat" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2011/02/setup-ruby-on-rails-3-for-development.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkIFRX0_fSp7ImA9WxBQGEQ.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-2637951338638052258</id><published>2010-01-18T17:01:00.008+05:00</published><updated>2010-01-19T15:55:14.345+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-19T15:55:14.345+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="testing" /><category scheme="http://www.blogger.com/atom/ns#" term="ActiveResource" /><category scheme="http://www.blogger.com/atom/ns#" term="Rails" /><title>Testing ActiveResource classes with Fakeweb and Shoulda</title><content type="html">It is not as simple to write unit tests for Active Resource models as they often depend on external web service. It is not mostly possible to get or create a Sandbox web service for unit testing your Active Resource classes. In such scenario you need a way to mock how the RESTful web service would behave in production.&lt;br /&gt;
&lt;br /&gt;
I initially tried to use &lt;a href="http://api.rubyonrails.org/classes/ActiveResource/HttpMock.html"&gt;HttpMock&lt;/a&gt; which is used to test Active Resource framework within Rails. It is undocumented and you need to dig through web and Rails documentation it self to see how it works. Recently I came across excellent &lt;a href="http://fakeweb.rubyforge.org/"&gt;FakeWeb&lt;/a&gt; gem and ever since that I have been hooked on it. I am impressed by simplicity with which we I can mock RESTFul Rails web services.  &lt;br /&gt;
&lt;br /&gt;
Here is how I use &lt;a href="http://www.ruby-doc.org/core/classes/Test/Unit.html"&gt;Test::Unit&lt;/a&gt; and &lt;a href="http://github.com/thoughtbot/shoulda"&gt;Shoulda&lt;/a&gt; with Rails to Mock RESTful web services for Active Resource classes. I am using XML based web services so I needed sample XML responses that Mock service should return. I create XML files containing those sample responses and store them under test/fixtures folder. After that I edited test_helper.rb file in test folder to have this utility method which loads sample responses from XML files located in fixtures folder.&lt;br /&gt;
&lt;br /&gt;
&lt;script src="http://gist.github.com/280837.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
After this lets jump on to unit test that we are going to write for our Active Resource class. Lets say we are testing an Active Resource class named User. Here is how I write unit test with FakeWeb and Shoulda gem.&lt;br /&gt;
&lt;br /&gt;
&lt;script src="http://gist.github.com/280840.js"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
First I am requiring both FakeWeb and Shoulda a gem. I would also add these gems to config/environments/test.rb as required gem for test environment.&lt;br /&gt;
&lt;br /&gt;
&lt;script src="http://gist.github.com/280852.js"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
After requiring these two gems I would disable real HTTP connections so not to mix real Web services calls with mock RESTful Web services by setting allow_net_connect property of FakeWeb class to false. Similarly in teardown method I would re-enable net HTTP connections by setting allow_net_connect property to true.&lt;br /&gt;
&lt;br /&gt;
Now I am going to write actual test using FakeWeb within Shoulda context blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;script src="http://gist.github.com/280846.js"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
Here within the context block I am setting up url to register as GET request to return response that is contained in XML file. After that a simple test checks the returned response object with some assertions. This shows how easy it is to create mock RESTful web services with FakeWeb and test your Active Resource classes with RSpec or &amp;nbsp;Test::Unit&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-2637951338638052258?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/5oGOHjjgQTWU719h8XGsSur7ojs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/5oGOHjjgQTWU719h8XGsSur7ojs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/5oGOHjjgQTWU719h8XGsSur7ojs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/5oGOHjjgQTWU719h8XGsSur7ojs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/IuJBnIp5F-o" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/2637951338638052258/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=2637951338638052258" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/2637951338638052258?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/2637951338638052258?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/IuJBnIp5F-o/testing-activeresource-classes-with.html" title="Testing ActiveResource classes with Fakeweb and Shoulda" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>4</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2010/01/testing-activeresource-classes-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEUDQnY8fCp7ImA9WxNXFE0.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-8844657722631420421</id><published>2009-10-01T18:57:00.002+06:00</published><updated>2009-10-01T19:04:33.874+06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-01T19:04:33.874+06:00</app:edited><title>Using Questions Answers Foo Plugin to add Q&amp;A to your Rails app</title><content type="html">Questions Answers plugin adds linkedin like Questions and Answers functionality to your&lt;br /&gt;Rails application. Plugin assumes existance of model named User and that model&lt;br /&gt;contains information about users of system. If User model does not exist the&lt;br /&gt;plugin will print warning message on console at startup. If you dont already&lt;br /&gt;have authentication user model i recommend you install restful_authentication&lt;br /&gt;plugin.&lt;br /&gt;&lt;br /&gt;The plugin uses login attribute of user model in views by default. You can&lt;br /&gt;change that default by declaring this constant in your environment.rb file&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; VIEW_QA_USER_ATTRIBUTE = "full_name"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;To change look of the module change the css refrenced in&lt;br /&gt;ui/views/layouts/qa.html.erb&lt;br /&gt;&lt;br /&gt;Install this plugin in your rails application by running&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; ./script/plugin install git://github.com/hasham2/questions_answers_foo.git&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;To complete installation of plugin run following rake task from root directory&lt;br /&gt;of your application.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; rake questions_answers:install&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This will create database migration to hold Questions and Answers data. After&lt;br /&gt;running this task run:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; rake db:migrate&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;to commit changes to database structure.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-8844657722631420421?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/DGJ1ViogDhsidSlo9qFTUrW5yoA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DGJ1ViogDhsidSlo9qFTUrW5yoA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/DGJ1ViogDhsidSlo9qFTUrW5yoA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DGJ1ViogDhsidSlo9qFTUrW5yoA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/NnlhzPyQd6o" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/8844657722631420421/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=8844657722631420421" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/8844657722631420421?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/8844657722631420421?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/NnlhzPyQd6o/questions-answers-foo-plugin-add-linked.html" title="Using Questions Answers Foo Plugin to add Q&amp;A to your Rails app" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2009/10/questions-answers-foo-plugin-add-linked.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cGQXo7fSp7ImA9WxJREEk.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-5836898289437910701</id><published>2009-05-11T19:37:00.002+06:00</published><updated>2009-05-11T19:37:00.405+06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-11T19:37:00.405+06:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Deployment" /><category scheme="http://www.blogger.com/atom/ns#" term="Ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="Rails" /><title>Deploying rails applications with vlad</title><content type="html">&lt;a href="http://rubyhitsquad.com/Vlad_the_Deployer.html"&gt;Vlad&lt;/a&gt; is application deployment automation tool much like &lt;a href="http://www.capify.org/"&gt;Capistrano&lt;/a&gt; but with much less complexity and it integrates right into &lt;a href="http://rake.rubyforge.org/"&gt;rake&lt;/a&gt;. so no need to capify your project again. Vlad is based on standard nix tools like ssh and rsync .&lt;br /&gt;&lt;br /&gt;To make it even better is that it comes with built in support for number of version control systems like Darcs, Subversion, Mercurial and best of all Git. To get started you need to install vlad gem on your machine and on each of servers you wish to deploy your ruby app.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;sudo gem install vlad&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The variables for deployment are typically setup in config/deploy.rb file just like capistrano. For trival one server deployment all you have to do is set four vaiables in deploy.rb file&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;set :application, "myblog"&lt;br /&gt;set :domain, "blog.com"&lt;br /&gt;set :deploy_to, "/var/rails/myblog"&lt;br /&gt;set :repository", "http://svn.myserver.com/myblog/trunk" &lt;/pre&gt; &lt;br /&gt;&lt;br /&gt;Also add following lines to Rakefile as well to require vlad gem &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Begin&lt;br /&gt; require 'vlad'&lt;br /&gt; Vlad.load&lt;br /&gt;rescue LoadError&lt;br /&gt; #do nothing&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Just run following commands in this sequence to deploy your application&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;vlad:setup #run first time only &lt;br /&gt;vlad:update &lt;br /&gt;vlad:migrate #optional&lt;br /&gt;vlad:start&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you might be aware Capistrano is not going to be maintained anymore by Jamis buck and there is lot of active development going on for vlad it should be good idea to give vlad a spin as alternative to capistrano.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-5836898289437910701?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TOC_S1AFItMapGTAp9LmLtYPCA8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TOC_S1AFItMapGTAp9LmLtYPCA8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TOC_S1AFItMapGTAp9LmLtYPCA8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TOC_S1AFItMapGTAp9LmLtYPCA8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/0VSzeeTmG-E" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/5836898289437910701/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=5836898289437910701" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/5836898289437910701?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/5836898289437910701?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/0VSzeeTmG-E/deploying-rails-applications-with-vlad.html" title="Deploying rails applications with vlad" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2009/05/deploying-rails-applications-with-vlad.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUcDRng7fSp7ImA9WxJREEk.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-8047581298413717809</id><published>2009-05-11T19:01:00.003+06:00</published><updated>2009-05-11T19:04:37.605+06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-11T19:04:37.605+06:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="Rails" /><title>DHH speaks of 5 years of ruby on rails and rails 3</title><content type="html">DHH's keynote on Railsconf 2009 speaks about five years of ruby on rails. Rails 3 and secret of high productivity. &lt;br /&gt;&lt;br /&gt;&lt;embed src="http://blip.tv/play/Af_XBIa8BA" type="application/x-shockwave-flash" width="640" height="390" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-8047581298413717809?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hrWSWs1yWubbWt0ffIZFQWxEows/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hrWSWs1yWubbWt0ffIZFQWxEows/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hrWSWs1yWubbWt0ffIZFQWxEows/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hrWSWs1yWubbWt0ffIZFQWxEows/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/S5LTRpxsfts" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/8047581298413717809/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=8047581298413717809" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/8047581298413717809?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/8047581298413717809?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/S5LTRpxsfts/dhh-speaks-of-5-years-of-ruby-on-rails.html" title="DHH speaks of 5 years of ruby on rails and rails 3" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2009/05/dhh-speaks-of-5-years-of-ruby-on-rails.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUCR389fSp7ImA9WxVVFko.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-4714764506798093695</id><published>2009-03-10T14:41:00.002+05:00</published><updated>2009-03-10T14:44:26.165+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-10T14:44:26.165+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="plugins" /><category scheme="http://www.blogger.com/atom/ns#" term="testing" /><category scheme="http://www.blogger.com/atom/ns#" term="Rails" /><title>using multiple contexts block in test case with shoulda</title><content type="html">&lt;p&gt;Test::Unit which is a default unit testing framework with rails. It has only one context for each test case class. If we can have more than one context per class than it could reduce number of files and classes that we are required to make to test cases in multiple contexts.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Answer to this issue is support for multiple contexts in Shoulda. Shoulda is rspec like testing framework built upon Test::Unit. Shoulda allows you to have multiple context with thier own setup and teardown methods. For example see this context block in a test case&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class UserTest &amp;lt; Test::Unit::TestCase&lt;br /&gt; context "with user" do&lt;br /&gt;   setup do&lt;br /&gt;     @user = User.create(:login =&amp;gt; "john", :password =&amp;gt; "secret" )&lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;   should "be able to authenticate" do&lt;br /&gt;     assert User.authenticate("john", "secret")&lt;br /&gt;   end &lt;br /&gt;&lt;br /&gt;   should "return authenticated user" do&lt;br /&gt;     assert_equal @user, User.authenticate("john", "secret")&lt;br /&gt;   end &lt;br /&gt; end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;For more details on shoulda testing framework take a look at official rails wiki &lt;a href="http://wiki.rubyonrails.org/testing/shoulda" target="_blank"&gt;page&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-4714764506798093695?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Mt4V8JSs2RSTVfw2Kekd1t3l-So/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Mt4V8JSs2RSTVfw2Kekd1t3l-So/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Mt4V8JSs2RSTVfw2Kekd1t3l-So/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Mt4V8JSs2RSTVfw2Kekd1t3l-So/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/pAj0x9fNCDw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/4714764506798093695/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=4714764506798093695" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/4714764506798093695?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/4714764506798093695?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/pAj0x9fNCDw/using-multiple-contexts-block-in-test.html" title="using multiple contexts block in test case with shoulda" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2009/03/using-multiple-contexts-block-in-test.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0EEQnc-fCp7ImA9WxdVEUw.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-8228521131384475507</id><published>2008-07-15T12:36:00.014+06:00</published><updated>2008-07-15T14:46:43.954+06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-07-15T14:46:43.954+06:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Deployment" /><category scheme="http://www.blogger.com/atom/ns#" term="Rails" /><title>Install Phusion Passenger on Cent OS 5</title><content type="html">Phusion Passenger (mod_rails/mod_rack) is an apache module that makes deployment of Ruby/Rails applications as simple as PHP applications. It does not require use of any ruby specific tools to deploy application. All you have to do is copy your source files in appropriate directories on server and your code changes will be deployed. Main advantage of passenger is it allows to deploy rails application reliably on shared hosting environment. Passenger is not available for windows. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets see how to install Passenger on Cent OS. Cent OS 5.1 comes with Apache 2.2.3 installed. First of all make sure Ruby, Gems, Rails and ruby development headers is installed on the system, Issue following commands as root: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;yum install ruby&lt;/div&gt;&lt;div&gt;yum install irb&lt;/div&gt;&lt;div&gt;yum install rdoc&lt;/div&gt;&lt;div&gt;yum install ruby-devel&lt;/div&gt;&lt;div&gt;yum install rubygems&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Now install rails gems:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;gem install rails -y&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also install Apache development header files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;yum install httpd-devel&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Now we have all prerequisites covered. Lets proceed with installation of Passenger gem.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;gem install passenger&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;After installing passenger and its dependencies make sure that Apache is stopped, launch passenger installer for Apache module from command line.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;passenger-install-apache2-module&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The command line based installer is pretty good it will check all dependencies and inform you if any dependency is missing. After the module is installed. create a rails application in /var/www/htdocs folder.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;rails demo&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Now open httpd.conf file in /etc/httpd/conf folder. Add following lines in this file.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.1/ext/apache2/mod_passenger.so&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.1&lt;/div&gt;&lt;div&gt;PassengerRuby /usr/bin/ruby&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;These paths could be different for your system. Now lets configure virtual host for rails application at bottom of httpd.conf. Add these lines at bottom of file:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&amp;lt;VirtualHost *:80&amp;gt;&lt;/div&gt;&lt;div&gt;      ServerName www.demo.com&lt;/div&gt;&lt;div&gt;      DocumentRoot /var/www/html/myapp/public&lt;/div&gt;&lt;div&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Make sure DocumentRoot points to public directory of your rails application. Also add server name alias to hosts file in /etc/ folder. Now start apache server from console.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;service httpd start&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Your new rails application should be running now with Phusion Passenger.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-8228521131384475507?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/G0LrtfznTUXUcVP9Tt3GyivUsM4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G0LrtfznTUXUcVP9Tt3GyivUsM4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/G0LrtfznTUXUcVP9Tt3GyivUsM4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G0LrtfznTUXUcVP9Tt3GyivUsM4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/fij5pbBI2UA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/8228521131384475507/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=8228521131384475507" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/8228521131384475507?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/8228521131384475507?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/fij5pbBI2UA/install-phusion-passenger-on-cent-os-5.html" title="Install Phusion Passenger on Cent OS 5" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2008/07/install-phusion-passenger-on-cent-os-5.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUIHSXg_fip7ImA9WxZVF00.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-7122456405969674601</id><published>2008-03-23T16:16:00.007+05:00</published><updated>2008-03-28T16:25:38.646+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-03-28T16:25:38.646+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="cms" /><category scheme="http://www.blogger.com/atom/ns#" term="Ruby" /><title>Radiant CMS 0.6 has extension now</title><content type="html">&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://radiantcms.org/images/logo.gif"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px;" src="http://radiantcms.org/images/logo.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://radiantcms.org/"&gt;Radiant&lt;/a&gt; is most promising content management system to come out from fast growing Ruby on Rails community. The &lt;a href="http://radiantcms.org/"&gt;Radiant site&lt;/a&gt; advertises it as no fluff cms intended for small teams.&lt;br /&gt;&lt;br /&gt;Radiant is fairly simple to install as gem and has structure common to all Ruby on Rails applications. No fluff means that there is no layers of code hiding core cms code and whole application code is simple to understand and change in true open source way.&lt;br /&gt;&lt;br /&gt;So what is keeping &lt;a href="http://radiantcms.org/"&gt;Radiant&lt;/a&gt; from replacing Joomla or Drupal as most popular open source cms out there. In my opinion at the moment the Ruby on Rails community is small (even when it is growing at stellar pace), let alone developer community around &lt;a href="http://radiantcms.org/"&gt;Radiant&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The reason for popularity of &lt;a href="http://www.joomla.org/"&gt;Joomla&lt;/a&gt; and similar PHP open source CMS is fact that they have been around for quite some time now. There is significant developer community around these projects which have been developing and extending these CMS. There is very large number of &lt;a href="http://extensions.joomla.org/"&gt;extensions&lt;/a&gt; available for Joomla allowing people to quickly mash up web applications into core cms.&lt;br /&gt;&lt;br /&gt;So most important thing for Radiant to be adopted by more teams especially ones outside Ruby on Rails community is to have popular extension mechanism and number of extensions available to extend core cms. Release 0.6 comes with extension mechanism which appears to be fairly simple and there are &lt;a href="http://wiki.radiantcms.org/Thirdparty_Extensions"&gt;some extensions&lt;/a&gt; available as well. Lets wait and see how many members of rails community contribute extensions to this project and will it be able to become leading open source cms as &lt;a href="http://www.joomla.org/"&gt;Joomla&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-7122456405969674601?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/NazSfPX3uHAKNVMulekACJHJmT4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NazSfPX3uHAKNVMulekACJHJmT4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/NazSfPX3uHAKNVMulekACJHJmT4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NazSfPX3uHAKNVMulekACJHJmT4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/df9C4U28NAU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/7122456405969674601/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=7122456405969674601" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/7122456405969674601?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/7122456405969674601?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/df9C4U28NAU/radiant-cms-06-has-extension-now.html" title="Radiant CMS 0.6 has extension now" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2008/03/radiant-cms-06-has-extension-now.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4FSX44eip7ImA9WxZWF0s.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-2331242786576893279</id><published>2008-03-17T17:34:00.007+05:00</published><updated>2008-03-17T18:35:18.032+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-03-17T18:35:18.032+05:00</app:edited><title>Getting started with Merb and Sequel Part 2</title><content type="html">Continuing from my last &lt;a href="http://hasham2.blogspot.com/2008/03/getting-started-with-merb-and-sequel.html"&gt;post&lt;/a&gt;. My previous post is based on merb 0.5, but since then newer merb 0.9.1 is available from &lt;a href="http://www.merbivore.com/"&gt;merbivore&lt;/a&gt;. There has been several changes in this release from previous version.&lt;br /&gt;Ok! Now lets add another model to our application to track user status. Type this command from your application root&lt;br /&gt;&lt;blockquote&gt;% merb-gen model status&lt;/blockquote&gt;This will create model named status.rb in app/models directory as well as migration file named 002_add_model_statuses.rb, Go on and edit this file to create the statuses table.&lt;br /&gt;&lt;blockquote&gt;class AddModelStatuses &lt; Sequel::Migration&lt;br /&gt;def up create_table :statuses do |u|    &lt;br /&gt;primary_key :id&lt;br /&gt;integer :user_id&lt;br /&gt;varchar :status, :size =&gt; 100&lt;br /&gt;text :note&lt;br /&gt;datetime :time_at&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def down&lt;br /&gt;execute "DROP TABLE statuses"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;/blockquote&gt;Now that we have status table setup lets manage the user status restfully. Lets create a controller for REST enabled actions.&lt;br /&gt;&lt;blockquote&gt;% merb-gen controller status&lt;/blockquote&gt;This will create a new contoller now add four actions to allow for REST protocol.&lt;br /&gt;&lt;blockquote&gt;class Statuses &lt; Application&lt;br /&gt; &lt;br /&gt;  # GET /statuses&lt;br /&gt;  # GET /statuses.xml&lt;br /&gt;  def index&lt;br /&gt;   @statuses = Status.filter('user_id = ?', session[:user_id])&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # GET /statuses/1&lt;br /&gt;  # GET /statuses/1.xml&lt;br /&gt;  def show&lt;br /&gt;   @status = Status.filter('id = ?', params[:id])&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # GET /statuses/new&lt;br /&gt;  def new&lt;br /&gt;&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # GET /statuses/1;edit&lt;br /&gt;  def edit&lt;br /&gt; &lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # POST /statuses&lt;br /&gt;  # POST /statuses.xml&lt;br /&gt;  def create&lt;br /&gt;    Status.insert(:user_id =&gt; session[:user_id], :status =&gt; params["select_status"], :note =&gt; params["status_note"], :time_at =&gt; Time.now)&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # PUT /statuses/1&lt;br /&gt;  # PUT /statuses/1.xml&lt;br /&gt;  def update&lt;br /&gt;    Status.filter('id = ?', params[:id]).update(:status =&gt; params["select_status"])&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # DELETE /statuses/1&lt;br /&gt;  # DELETE /statuses/1.xml&lt;br /&gt;  def destroy&lt;br /&gt;    Status.filter(:id =&gt; params[:id]).delete&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;/blockquote&gt;Now that we have this in controller, lets setup router.rb to use this controller restfully, Add thi s line to router.rb&lt;br /&gt;&lt;blockquote&gt;r.resources :statuses&lt;/blockquote&gt;Now you can call the the statuses controller restfully from anywhere. Check out Ezra's &lt;a href="http://brainspl.at/articles/2007/01/25/merb-gets-restfull-routes"&gt;post&lt;/a&gt; on Restful routes&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-2331242786576893279?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/l5IHGGaTpHzd0eyA6giTdNxjlf8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/l5IHGGaTpHzd0eyA6giTdNxjlf8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/l5IHGGaTpHzd0eyA6giTdNxjlf8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/l5IHGGaTpHzd0eyA6giTdNxjlf8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/9JKwYjPbDas" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/2331242786576893279/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=2331242786576893279" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/2331242786576893279?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/2331242786576893279?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/9JKwYjPbDas/getting-started-with-merb-and-sequel_17.html" title="Getting started with Merb and Sequel Part 2" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2008/03/getting-started-with-merb-and-sequel_17.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0YGQnYzfSp7ImA9WxZXFUk.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-3770010816610569758</id><published>2008-03-02T19:21:00.030+05:00</published><updated>2008-03-03T15:45:23.885+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-03-03T15:45:23.885+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="Sequel" /><category scheme="http://www.blogger.com/atom/ns#" term="Merb" /><title>Getting started with Merb and Sequel Part 1</title><content type="html">&lt;a href="http://www.merbivore.com/"&gt;Merb&lt;/a&gt; is a new super fast, multi threaded, Ruby based MVC Framework based on Mongrel and Embedded Ruby. Developer of merb is &lt;a href="http://www.workingwithrails.com/person/5421-ezra-zygmuntowicz"&gt;Ezra Zygmuntowicz&lt;/a&gt; of &lt;a href="http://www.engineyard.com/"&gt;engine yard&lt;/a&gt; fame.  The latest release of merb is based on &lt;a href="http://rack.rubyforge.org/"&gt;rack&lt;/a&gt; which is common interface between various web servers and  ruby frameworks. So now merb is no longer bound to mongrel only.&lt;br /&gt;&lt;br /&gt;Merb does not force developers to stick to one thing unlike &lt;a href="http://www.rubyonrails.org/"&gt;Rails&lt;/a&gt;.  The merb allows developers to choose from three different ORM's i.e.&lt;a href="http://wiki.rubyonrails.org/rails/pages/ActiveRecord"&gt; Active Record&lt;/a&gt;, &lt;a href="http://datamapper.org/"&gt;Data mapper&lt;/a&gt; and &lt;a href="http://code.google.com/p/ruby-sequel/"&gt;Sequel&lt;/a&gt;. Merb is also Multi threaded as long as you don't use Active Record as ORM, that means you dont need to run pack of mongrels like Rails.&lt;br /&gt;&lt;br /&gt;Lets built a small web application to check out merb. In my example i ll be using Sequel ORM with merb. so go ahead and install merb and Sequel. Type this on command line:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;% sudo gem install merb --include-dependencies&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;after that&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;% sudo gem install merb_sequel&lt;/blockquote&gt;Now lets create application directory structure:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;% merb time_management&lt;/blockquote&gt;As you can see we are going to make little time management application for this tutorial. First of all we need to tell merb that we intend to use Sequel in this application. Open file named dependencies.rb in config folder below application root, uncomment this line:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;use_orm :sequel&lt;/blockquote&gt;Now simply run merb command from your application root. This will create a file named database.sample.yml in config folder. Change parameters in this file and save it as database.yml in same config folder. The database.yml syntax is similar to rails database.yml file. Here is how database.yml file looks like:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;---&lt;br /&gt;# This is a sample database file for the Sequel ORM&lt;br /&gt;:development: &amp;amp;defaults&lt;br /&gt;:adapter: mysql&lt;br /&gt;:database: ts_development&lt;br /&gt;:username: root&lt;br /&gt;:password:&lt;br /&gt;:host: localhost&lt;br /&gt;:socket: /tmp/mysql.sock&lt;br /&gt;&lt;br /&gt;:test:&lt;br /&gt;&lt;&lt;: *defaults   :database: ts_test   &lt;br /&gt;&lt;br /&gt;:production:  &lt;br /&gt;&lt;&lt;: *defaults   :database: ts_production &lt;/blockquote&gt;Now we have database setup lets create a model now. The merb has generators to create models, controllers and specs just like rails.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;% ./script/generate model user&lt;br /&gt;&lt;/blockquote&gt;this will create bunch of files like model named user.rb in app/models folder. Among these files it also creates migration named like 001_add_model_users.rb in schema/migrations folder. Now lets write some code in this migration to create users table. The Sequel migration syntax is different from  Active Record.  Look at &lt;a href="http://code.google.com/p/ruby-sequel/wiki/Migrations"&gt;documentation&lt;/a&gt; for more details. Here is how migration would look like after editing:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;class AddModelUsers &lt; Sequel::Migration &lt;br /&gt;def up create_table :users do |u|     &lt;br /&gt;primary_key :id&lt;br /&gt;varchar :first_name, :size =&gt; 100&lt;br /&gt;varchar :last_name, :size =&gt; 100&lt;br /&gt;varchar :user_name, :null =&gt; false&lt;br /&gt;varchar :password, :null =&gt; false&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def down&lt;br /&gt;execute "DROP TABLE users"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Now that table is created lets create a controller, leave model empty for now later on some business logic can go into models.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;% ./script/generate controller main&lt;/blockquote&gt;This will create file named main.rb in app/controllers folder .  Notice there is already file name application.rb in controllers folder. All controllers inherit from this Application class so common controller code can go in this Application class. Now lets write login and logout functionality in main.rb file.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;class Main &lt; Application&lt;br /&gt;&lt;br /&gt;def index&lt;br /&gt;render&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def login&lt;br /&gt;@error =false&lt;br /&gt;uname = params.fetch(:uname)&lt;br /&gt;pass = params.fetch(:pass)&lt;br /&gt;user = User.filter(:user_name =&gt; uname, :password =&gt; pass)&lt;br /&gt;unless @user.blank?                      &lt;br /&gt;             session[:user_id] = @user.first.id&lt;br /&gt;             redirect "/main/"&lt;br /&gt;        else&lt;br /&gt;            @error = true&lt;br /&gt;        end&lt;br /&gt;   end&lt;br /&gt;   if session[:user_id] != nil&lt;br /&gt;       @logged_in = true&lt;br /&gt;       @user = User.filter(:id =&gt; session[:user_id]).first&lt;br /&gt;   else&lt;br /&gt;       @logged_in = false&lt;br /&gt;   end&lt;br /&gt;   render&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;def logout&lt;br /&gt;    session[:user_id] = nil&lt;br /&gt;    redirect "/main/"&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;/blockquote&gt;There are two things to notice here for rails programmers one is the way you fetch values from params that are passed to each action. We call fetch method on params object to get variables that are passed with the request for that action. Other is Sequel syntax of model which uses filter instead of find. For more detailed syntax take a look at &lt;a href="http://code.google.com/p/ruby-sequel/wiki/FilteringRecords"&gt;documentation&lt;/a&gt;.&lt;br /&gt;Another thing to look at is explicit call to render function. Which renders erb template located in app/views folder e.g. index.html.erb for index action. The templates are pure embedded ruby .  The creators of merb claims that it is drop in replacement of rails Action pack. True there is not much difference.  Lets change a default route to point to index action of main controller. Change config/router.rb to add this line:&lt;br /&gt;&lt;blockquote&gt;r.match("/").to(:controller =&gt; "main", :action =&gt; "index")&lt;/blockquote&gt;&lt;br /&gt;above this line&lt;br /&gt;&lt;blockquote&gt;r.default_routes&lt;/blockquote&gt;Start our sample application by running merb command in our application root:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;% merb&lt;/blockquote&gt;If all goes well you should be able to access your sample application at &lt;a href="http://127.0.0.1:4000/"&gt;http://127.0.0.1:4000/ &lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Lets add few more things to our application in next part ....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-3770010816610569758?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/RYxPRDQoaYiHG1NwdyExkUuTiME/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RYxPRDQoaYiHG1NwdyExkUuTiME/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/RYxPRDQoaYiHG1NwdyExkUuTiME/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RYxPRDQoaYiHG1NwdyExkUuTiME/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/1MEtKrHHdas" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/3770010816610569758/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=3770010816610569758" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/3770010816610569758?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/3770010816610569758?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/1MEtKrHHdas/getting-started-with-merb-and-sequel.html" title="Getting started with Merb and Sequel Part 1" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>8</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2008/03/getting-started-with-merb-and-sequel.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcEQno-cCp7ImA9WxZXEE8.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-2106081722813652525</id><published>2008-02-26T15:26:00.003+05:00</published><updated>2008-02-26T15:50:03.458+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-02-26T15:50:03.458+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="TinyMCE" /><category scheme="http://www.blogger.com/atom/ns#" term="Rails" /><title>Getting TinyMCE 3.0 Spellchecker to work with Rails</title><content type="html">In new version of &lt;a href="http://tinymce.moxiecode.com/"&gt;TinyMCE&lt;/a&gt; editor there are many changes in plug ins. The Plug in code is changed. The popular &lt;a href="http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker"&gt;spell checker plug in&lt;/a&gt; now uses   JSON as transport mechanism instead of XML. In my example we are using Aspell to check spellings, so you must have Aspell installed on your system for this example to work&lt;br /&gt;&lt;br /&gt;Issue this command on CLI to check if Aspell is installed:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;% aspell&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;You should see help output related to command&lt;br /&gt;&lt;br /&gt;First of all you need to install JSON gem to parse JSON requests&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;% sudo gem install json&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Then write this action in a controller:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;require json&lt;br /&gt;&lt;br /&gt;def spellcheck&lt;br /&gt;raw = request.env['RAW_POST_DATA']&lt;br /&gt;req = JSON.parse(raw)&lt;br /&gt;lang = req["params"][0]&lt;br /&gt;if req["method"] == 'checkWords'&lt;br /&gt;  text_to_check = req["params"][1].join(" ")&lt;br /&gt;else&lt;br /&gt;  text_to_check = req["params"][1]&lt;br /&gt;end&lt;br /&gt;suggestions = check_spelling_new(text_to_check, req["method"], lang)&lt;br /&gt;render :json =&amp;gt; {"id" =&amp;gt; nil, "result" =&amp;gt; suggestions, "error" =&amp;gt; nil}.to_json&lt;br /&gt;return  &lt;br /&gt;end&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Now also write this method in private section of controller:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;def check_spelling_new(spell_check_text, command, lang)&lt;br /&gt;json_response_values = Array.new&lt;br /&gt;spell_check_response = `echo "#{spell_check_text}" | aspell -a -l #{lang}`&lt;br /&gt;if (spell_check_response != '')   &lt;br /&gt;  spelling_errors = spell_check_response.split(' ').slice(1..-1)&lt;br /&gt;  if (command == 'checkWords')&lt;br /&gt;    i = 0&lt;br /&gt;    while i &amp;lt; spelling_errors.length&lt;br /&gt;      spelling_errors[i].strip!&lt;br /&gt;      if (spelling_errors[i].to_s.index('&amp;amp;') == 0)&lt;br /&gt;        match_data = spelling_errors[i + 1]                   &lt;br /&gt;        json_response_values &amp;lt;&amp;lt; match_data          &lt;br /&gt;      end&lt;br /&gt;      i += 1        &lt;br /&gt;    end&lt;br /&gt;  elsif (command == 'getSuggestions')&lt;br /&gt;    arr = spell_check_response.split(':')&lt;br /&gt;    suggestion_string = arr[1]&lt;br /&gt;    suggestions = suggestion_string.split(',')     &lt;br /&gt;    for suggestion in suggestions&lt;br /&gt;      suggestion.strip!&lt;br /&gt;      json_response_values &amp;lt;&amp;lt; suggestion       &lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end   &lt;br /&gt;return json_response_values&lt;br /&gt;end&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;now you need to open /plugins/spellchecker/editor_plugin.js file under your Tiny MCE directory. Search for this line;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;t.url = url;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;and change it to:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;t.url = 'http://www.yourhostname.com';&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;then search for this line:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;var t = this, url = t.editor.getParam("spellchecker_rpc_url", this.url+'/rpc.php');&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;and change it to:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;var t = this, url = t.editor.getParam("spellchecker_rpc_url", this.url+'/spellcheck');&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;and to make this work just add this route to routes.rb under config folder&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;map.connect '/spellcheck', :controller =&gt; 'your_controller_name', :action =&gt; 'spellcheck'&lt;br /&gt;#replace your_controller_name with name of our controller in which the spellcheck action is written&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-2106081722813652525?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/y86izQyCS7K99yCfX5_ESI0jdvw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/y86izQyCS7K99yCfX5_ESI0jdvw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/y86izQyCS7K99yCfX5_ESI0jdvw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/y86izQyCS7K99yCfX5_ESI0jdvw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/QfE-OBwNQ9M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/2106081722813652525/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=2106081722813652525" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/2106081722813652525?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/2106081722813652525?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/QfE-OBwNQ9M/getting-tinymce-30-spellchecker-to-work.html" title="Getting TinyMCE 3.0 Spellchecker to work with Rails" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>6</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2008/02/getting-tinymce-30-spellchecker-to-work.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkQCQHY5eyp7ImA9WB9XFE4.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-5967754144177644650</id><published>2007-11-07T17:18:00.001+05:00</published><updated>2007-11-07T17:26:01.823+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-07T17:26:01.823+05:00</app:edited><title>No default PTY in  Capistrano 2.1</title><content type="html">Add this line your Capistrano scripts to work with new Capistrano 2.1 gem.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;default_run_options[:pty] = true&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Capistrano no longer requests a pty on each command, which means your .profile (or .bashrc etc) will be properly loaded on each command. Some commands will go into non-interactive mode automatically. If you’re not seeing commands at CLI, You can return to old behavior by adding this line to your deploy.rb &lt;br /&gt;&lt;br /&gt;For more changes in Capistrano 2.1&amp;nbsp;  &lt;br /&gt;&lt;a href="http://weblog.jamisbuck.org/2007/10/14/capistrano-2-1"&gt;http://weblog.jamisbuck.org/2007/10/14/capistrano-2-1&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-5967754144177644650?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/IzGxDleiL_NhBDO9woXwnf3iNaE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/IzGxDleiL_NhBDO9woXwnf3iNaE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/IzGxDleiL_NhBDO9woXwnf3iNaE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/IzGxDleiL_NhBDO9woXwnf3iNaE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/vp7qwbuds0s" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/5967754144177644650/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=5967754144177644650" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/5967754144177644650?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/5967754144177644650?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/vp7qwbuds0s/no-default-pty-in-capistrano-21.html" title="No default PTY in  Capistrano 2.1" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/11/no-default-pty-in-capistrano-21.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkcDR3s7cSp7ImA9WB9QEk8.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-5934415173181756792</id><published>2007-10-24T15:01:00.001+05:00</published><updated>2007-10-24T15:01:16.509+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-24T15:01:16.509+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="railserb templates" /><title>Multiview Templates in Rails 2.0</title><content type="html">Along with many other enhancements and changes in Rails 2.0 now there are new multi view templates. I think multi view templates are going to be most visible and important change in Rails 2.0. &lt;br /&gt;&lt;br /&gt;What essentially has happened is that template format has been separated from&amp;nbsp; rendering engine. This allows you to parse any type of template (csv, haml, rtf etc)&amp;nbsp;  with erb rendering engine. So this takes respond_to&amp;nbsp; next level by having different template format for each respond_to.&lt;br /&gt;&lt;br /&gt;So the new format for templates is action.format.renderer (i.e. show.html.erb, show.rtf.erb etc). you can declare own mime-type aliases in the config/initializers/mime_types.rb file. This file is included by default in all new applications.&lt;br /&gt;&lt;br /&gt;For other new features coming in rails 2.0&lt;br /&gt;&lt;br /&gt;&lt;a href="http://weblog.rubyonrails.org/2007/9/30/rails-2-0-0-preview-release"&gt;http://weblog.rubyonrails.org/2007/9/30/rails-2-0-0-preview-release&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-5934415173181756792?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/w-XKhu0h88lx8mM2M3PP-ZNyofQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/w-XKhu0h88lx8mM2M3PP-ZNyofQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/w-XKhu0h88lx8mM2M3PP-ZNyofQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/w-XKhu0h88lx8mM2M3PP-ZNyofQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/v9f0_jBriBE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/5934415173181756792/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=5934415173181756792" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/5934415173181756792?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/5934415173181756792?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/v9f0_jBriBE/multiview-templates-in-rails-20.html" title="Multiview Templates in Rails 2.0" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/10/multiview-templates-in-rails-20.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUCSXg7fSp7ImA9WB5UFE4.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-3553538926052251373</id><published>2007-08-18T16:33:00.000+05:00</published><updated>2007-08-18T16:57:48.605+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-08-18T16:57:48.605+05:00</app:edited><title>Using .Net SOAP Services with wsdl2ruby</title><content type="html">Easist way to use SOAP service in pure ruby is with wsdl2ruby. Simplest code would be to:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt; require 'soap/wsdlDriver'&lt;br /&gt; wsdl = 'http://www.dotnetsite.com/MyService/Service.asmx?WSDL&lt;br /&gt; driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver&lt;br /&gt; puts driver.GetVals(:parameter =&gt; SOAP::SOAPInt.new(136)) &lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Where GetVals is .Net web method to call. Generating stub files with wsdl2ruby.rb against a WSDL could what arguments you should pass. &lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt; % wsdl2ruby.rb --wsdl Foo.wsdl --type client --force &lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;I would like to thank Hiroshi NAKAMURA for this last information&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-3553538926052251373?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Md-MseTAGajtg4pRkqEW_CP8FBc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Md-MseTAGajtg4pRkqEW_CP8FBc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Md-MseTAGajtg4pRkqEW_CP8FBc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Md-MseTAGajtg4pRkqEW_CP8FBc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/CHwfNPJE23A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/3553538926052251373/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=3553538926052251373" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/3553538926052251373?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/3553538926052251373?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/CHwfNPJE23A/using-net-soap-services-with-wsdl2ruby.html" title="Using .Net SOAP Services with wsdl2ruby" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/08/using-net-soap-services-with-wsdl2ruby.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D08MQHo4fyp7ImA9WB5QFUg.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-113169366717069222</id><published>2007-07-04T17:55:00.000+05:00</published><updated>2007-07-04T18:31:21.437+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-07-04T18:31:21.437+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="plugins" /><title>Using Gravatar plugin to embed avatars in rails views</title><content type="html">&lt;a href="http://www.gravatar.com/"&gt;Gravatar&lt;/a&gt; offers service to keep your globally recognizable avatars (&lt;span style="font-style: italic;"&gt;gravatar&lt;/span&gt;). This tiny plugin offers rails view helper to embed gravatars in your views. It can also be used in blog, forums applications to insert gravatar to be visible instead of email. Here is how to install it:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;$ ruby script/plugin install http://tools.assembla.com/svn/hasham/plugins/gravatar_tag&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Here is sample usage in an erb template:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt; &lt;%= gravatar_tag "user@domain.com", :size =&gt; "60x60"%&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;The first parameter which is a email that user signed up with on &lt;a href="http://www.gravatar.com"&gt;gravatar.com&lt;/a&gt; is required. The other parameters are same as rails image_tag view helper.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-113169366717069222?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/nS2hkZRLcoj_d4ddq67bjFwqx48/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nS2hkZRLcoj_d4ddq67bjFwqx48/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/nS2hkZRLcoj_d4ddq67bjFwqx48/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nS2hkZRLcoj_d4ddq67bjFwqx48/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/o2SVQpbQhXM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/113169366717069222/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=113169366717069222" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/113169366717069222?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/113169366717069222?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/o2SVQpbQhXM/using-gravatar-plugin-to-embed-avatars.html" title="Using Gravatar plugin to embed avatars in rails views" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/07/using-gravatar-plugin-to-embed-avatars.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkMAQH88fCp7ImA9WB5QE0s.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-2435885411877183684</id><published>2007-07-02T14:13:00.000+05:00</published><updated>2007-07-02T14:27:21.174+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-07-02T14:27:21.174+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="svn capistrano" /><title>SVN Cache made simple with Capistrano 2</title><content type="html">You normally don't want to do complete checkout of your source control on every deployment with Capistrano.  The SVN cache keeps copy of source code on server in separate directory on  each deploy this copy of source code is updated  and deployed to releases directory. &lt;br /&gt;&lt;br /&gt;Implementing this kind of SVN cache is super simple in Capistrano 2, Just set deploy_via variable to remote_cache like this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;set :deploy_via, :remote_cache&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-2435885411877183684?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/dAtzVeiT1Jovf01jkbbYY69ebEM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dAtzVeiT1Jovf01jkbbYY69ebEM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/dAtzVeiT1Jovf01jkbbYY69ebEM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dAtzVeiT1Jovf01jkbbYY69ebEM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/HXRIS90I3Rs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/2435885411877183684/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=2435885411877183684" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/2435885411877183684?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/2435885411877183684?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/HXRIS90I3Rs/svn-cache-made-simple-with-capistrano-2.html" title="SVN Cache made simple with Capistrano 2" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/07/svn-cache-made-simple-with-capistrano-2.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUCRXg4cCp7ImA9WB5QEkQ.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-4386857944705085555</id><published>2007-07-01T18:40:00.000+05:00</published><updated>2007-07-01T18:57:44.638+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-07-01T18:57:44.638+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mongrel" /><title>Mongrel is multi threaded, but rails is not thread safe</title><content type="html">The main reason why we need to run multiple &lt;a href="http://mongrel.rubyforge.org/"&gt;mongrel&lt;/a&gt; instances (pack of mongrels) for any high traffic website is that Ruby on Rails code is not thread safe. This is not the case with other Ruby frameworks like Camping, Merb and Og + Nitro.  There is a  synchronized block around the calls to Dispatcher.dispatch (in dispatch.rb) rest is multithreaded. so to get any sort of concurrency in serving request we need to run multiple mongrel instances.&lt;br /&gt;&lt;br /&gt;In my experience 128 MB RAM is required to run single instance of mongrel server. which means you should not run more than 8 mongrels on your 1 GB RAM VPS. If the rails could be thread safe it would require lot less server resources to deploy rails with mongrels.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-4386857944705085555?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hY3pZPSJ-p657utaUZcy1efklZ8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hY3pZPSJ-p657utaUZcy1efklZ8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hY3pZPSJ-p657utaUZcy1efklZ8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hY3pZPSJ-p657utaUZcy1efklZ8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/JltkFq2H0Xg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/4386857944705085555/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=4386857944705085555" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/4386857944705085555?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/4386857944705085555?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/JltkFq2H0Xg/mongrel-is-multi-threaded-but-rails-is.html" title="Mongrel is multi threaded, but rails is not thread safe" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/07/mongrel-is-multi-threaded-but-rails-is.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEIHR3k5fyp7ImA9WB5QEE4.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-8598078533107724130</id><published>2007-06-28T13:18:00.000+05:00</published><updated>2007-06-28T18:15:36.727+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-06-28T18:15:36.727+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="plugins" /><category scheme="http://www.blogger.com/atom/ns#" term="exceptions" /><title>Ignoring common exceptions in exception_notification plugin</title><content type="html">&lt;a href="http://dev.rubyonrails.org/svn/rails/plugins/exception_notification/"&gt;Exception Notification&lt;/a&gt; is a great plugin, that helps to you to get trace of exception on your app running in production mode. Without this plugin you probably would have to SSH to production machine and tail the production.log file to get last exception trace which is extremely inconvenient to do. FTP to get to production.log is also an option but production.log files tend to become too large. only problem is that you may get too many emails form this plugin especially when you have just launched your site in production mode.&lt;br /&gt;&lt;br /&gt;some of the exception are not too much intresting like typical ActiveRecord::RecordNotFound exceptions, To ignore these kind of trivial exceptions you must overide it in rescue_action_in_public method of your application.rb file.&lt;br /&gt;&lt;br /&gt;Here is how you do it:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;def rescue_action_in_public(exception)&lt;br /&gt; case exception&lt;br /&gt;  when ::ActiveRecord::RecordNotFound,&lt;br /&gt;       ::ActionController::UnknownController,&lt;br /&gt;       ::ActionController::UnknownAction,&lt;br /&gt;       ::ActionController::RoutingError&lt;br /&gt;         render_404&lt;br /&gt;  else&lt;br /&gt;       render_500 &lt;br /&gt;       deliverer = self.class.exception_data&lt;br /&gt;         data = case deliverer&lt;br /&gt;                when nil then {}&lt;br /&gt;                when Symbol then send(deliverer)&lt;br /&gt;                when Proc then deliverer.call(self)&lt;br /&gt;         end&lt;br /&gt;      ExceptionNotifier.deliver_exception_notification(exception, self, request, data)&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-8598078533107724130?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CUua_NLCzSPF5o_5opnTJECLxa4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CUua_NLCzSPF5o_5opnTJECLxa4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CUua_NLCzSPF5o_5opnTJECLxa4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CUua_NLCzSPF5o_5opnTJECLxa4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/uhV_t9mV4_Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/8598078533107724130/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=8598078533107724130" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/8598078533107724130?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/8598078533107724130?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/uhV_t9mV4_Y/gnoring-common-exceptions-in.html" title="Ignoring common exceptions in exception_notification plugin" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/06/gnoring-common-exceptions-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEIDSX4zfyp7ImA9WB5QEE4.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-4749092890480031565</id><published>2007-06-24T17:09:00.000+05:00</published><updated>2007-06-28T18:16:18.087+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-06-28T18:16:18.087+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="capistrano" /><category scheme="http://www.blogger.com/atom/ns#" term="svn" /><title>Capistrano 2 and custom SCM modules</title><content type="html">I was using Capistrano 2 to deploy our latest project, as we had our SVN repository behind the corporate firewall and was not accessible remotely. I had originally planned to use a custom &lt;a href="http://blog.wolfman.com/articles/2006/12/06/a-capistrano-scm-module-for-local-svn-access"&gt;SCM module for local svn access.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I discovered that &lt;a href="http://www.capify.org/upgrade/gotchas"&gt;custom SCM modules are not supported &lt;/a&gt;at the moment in Capistrano 2.&lt;br /&gt;&lt;br /&gt;If there are any workarounds i would be interested to know about them&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-4749092890480031565?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/7scECxvDSlzQG8xektFbwo40-qY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7scECxvDSlzQG8xektFbwo40-qY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/7scECxvDSlzQG8xektFbwo40-qY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7scECxvDSlzQG8xektFbwo40-qY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/xid_7gpypjE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/4749092890480031565/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=4749092890480031565" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/4749092890480031565?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/4749092890480031565?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/xid_7gpypjE/capistrano-2-and-custom-scm-modules.html" title="Capistrano 2 and custom SCM modules" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/06/capistrano-2-and-custom-scm-modules.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQHRn48fip7ImA9WBFQGUU.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-5018757070322751322</id><published>2007-03-16T00:12:00.000+05:00</published><updated>2007-03-16T00:18:57.076+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-03-16T00:18:57.076+05:00</app:edited><title>STI vs. Polymorphic association</title><content type="html">This is a common to have join between two tables based on condition. suppose we have table in database called comments and we can have comments on different thing like a video, profile or picture. So keeping DRY (Don’t repeat yourself) principle in mind while designing your database. You may want to have relationship between single comments table and videos or profiles table.&lt;br /&gt;&lt;br /&gt;At database level you should have two fields in table one field (i.e. type) that identifies the type of comment whether it is a comment on video or it’s a comment on profile, and another field (i.e source_id) that contains id of the video or profile that comment was on.&lt;br /&gt;&lt;br /&gt;In Ruby on Rails currently there are two ways to define this kind of association between your activerecord models:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Single Table Inheritance:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here you ‘ll create a single table of comments and Comment AR class, there would be two additional classes ProfileComment and VideoComment inheriting from same Comment AR class. Instead of having association between Profile and Comment model there would be association between Profile and ProfileComment subclass. Same will be the case with Video model and VideoComment subclass.&lt;br /&gt;&lt;br /&gt;If we take a look at comment table we ‘ll see that class name for each record will be automatically stored in type field. The reference to associated table would be in source_id field.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;class Comment &lt; ActiveRecord::Base&lt;br /&gt;end&lt;br /&gt;class VideoComment &lt; Comment       &lt;br /&gt;    belongs_to :video, :foreign_key =&gt; “source_id”&lt;br /&gt;end&lt;br /&gt;class ProfileComment &lt; Comment&lt;br /&gt;    belongs_to :profile, :foreign_key =&gt; “source_id”&lt;br /&gt;end&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Polymorphic Association:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since Rails 1.1 there is a simpler way to create this kind of relationship called polymorphic association. In case of polymorphic association you ‘ll have two fields called commentable_type and commentable_id, instead of type and source_id. The commentable_type field will store name of class which that instance relates to and commentable_id saves the reference to instance of that class. The relations will be created like this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;class Comment &lt; ActiveRecord::Base&lt;br /&gt;    belongs_to :commentable, :polymorphic =&gt; true&lt;br /&gt;end&lt;br /&gt;class Video &lt; ActiveRecord::Base&lt;br /&gt;    has_many :comments, :as =&gt; :commentable&lt;br /&gt;end&lt;br /&gt;class Profile &lt; ActiveRecord::Base&lt;br /&gt;    has_many :comments, :as =&gt; :commentable&lt;br /&gt;end&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Pros and Cons:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;     The STI approach offers more flexibilty by allowing you to have additional fields that only have value in case of one sub class. For access from other sub class can be disallowed be overridden accessors.&lt;/li&gt;&lt;li&gt;     The STI requires you to create a seperate class to implement a relation between two models, resulting in more classses. which is not case with polymorphic association&lt;/li&gt;&lt;li&gt;     The STI results in more code.It is confusing to some programmers to understand relation between STI classes&lt;/li&gt;&lt;li&gt;     The polymorphic association is very easy to implement.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-5018757070322751322?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/DoBmn0Tboppi__blXvkQeaVUdgk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DoBmn0Tboppi__blXvkQeaVUdgk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/DoBmn0Tboppi__blXvkQeaVUdgk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DoBmn0Tboppi__blXvkQeaVUdgk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/-ZDohpbJQtk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/5018757070322751322/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=5018757070322751322" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/5018757070322751322?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/5018757070322751322?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/-ZDohpbJQtk/sti-vs-polymorphic-association.html" title="STI vs. Polymorphic association" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>5</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/03/sti-vs-polymorphic-association.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4MQHk9fip7ImA9WBFQGUg.&quot;"><id>tag:blogger.com,1999:blog-3692287593494445131.post-7107419871685574415</id><published>2007-03-15T14:44:00.000+05:00</published><updated>2007-03-15T15:36:21.766+05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-03-15T15:36:21.766+05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="hpricot" /><category scheme="http://www.blogger.com/atom/ns#" term="https" /><title>Using Net::https with Hpricot to parse html</title><content type="html">My rails app that accessed sites to extract images from web pages started throwing this error (OpenSSL::SSL::SSLError). I was using open-uri to fetch pages.&lt;br /&gt;&lt;br /&gt;I changed my code to use Net::https to fetch pages over SSL. Here is sample code to access a web page and print it contents to terminal over SSL. &lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;require 'rubygems'&lt;br /&gt;require 'hpricot'&lt;br /&gt;require 'uri'&lt;br /&gt;require 'net/https'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;url = "https://www.orkut.com/GLogin.aspx?done=http%3A%2F%2Fwww.orkut.com%2F"&lt;br /&gt;&lt;br /&gt;url1 = URI.parse(url)&lt;br /&gt;&lt;br /&gt;http = Net::HTTP.new(url1.host, url1.port)&lt;br /&gt;http.use_ssl = true&lt;br /&gt;&lt;br /&gt;req = Net::HTTP::Get.new(url1.path)&lt;br /&gt;&lt;br /&gt;res = http.start do |http|&lt;br /&gt;   http.request(req)&lt;br /&gt; end&lt;br /&gt;&lt;br /&gt;puts res.body&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3692287593494445131-7107419871685574415?l=hasham2.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/g1T9S6FbEYmKKqwwLoabZuYIKTs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/g1T9S6FbEYmKKqwwLoabZuYIKTs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/g1T9S6FbEYmKKqwwLoabZuYIKTs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/g1T9S6FbEYmKKqwwLoabZuYIKTs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Pakistanirb/~4/x8dUUDRbKDQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://hasham2.blogspot.com/feeds/7107419871685574415/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3692287593494445131&amp;postID=7107419871685574415" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/7107419871685574415?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3692287593494445131/posts/default/7107419871685574415?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Pakistanirb/~3/x8dUUDRbKDQ/using-nethttps-with-hpricot-to-parse.html" title="Using Net::https with Hpricot to parse html" /><author><name>Hasham Malik</name><uri>http://www.blogger.com/profile/15587443973138053640</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="26" height="32" src="http://farm2.static.flickr.com/1196/645086847_5846b2b31e.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://hasham2.blogspot.com/2007/03/using-nethttps-with-hpricot-to-parse.html</feedburner:origLink></entry></feed>

