<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Subhashmohan&#039;s Blog</title>
	<atom:link href="http://subhashmohan.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://subhashmohan.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 23 Aug 2011 04:18:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='subhashmohan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Subhashmohan&#039;s Blog</title>
		<link>http://subhashmohan.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://subhashmohan.wordpress.com/osd.xml" title="Subhashmohan&#039;s Blog" />
	<atom:link rel='hub' href='http://subhashmohan.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Active Scaffold : Add checkbox array for a particular field</title>
		<link>http://subhashmohan.wordpress.com/2010/11/18/active-scaffold-add-checkbox-array-for-a-particular-field/</link>
		<comments>http://subhashmohan.wordpress.com/2010/11/18/active-scaffold-add-checkbox-array-for-a-particular-field/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 13:12:53 +0000</pubDate>
		<dc:creator>Subhash Mohan</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[active scaffold]]></category>

		<guid isPermaLink="false">http://subhashmohan.wordpress.com/?p=121</guid>
		<description><![CDATA[Suppose you have a field in your table, which accepts array of values through multiple checkboxes, then here is a way to show these checkboxes on your active scaffold create/update form. #Controller class UsersController &#60; ApplicationController active_scaffold :user do &#124;config&#124; config.label = “Users” config.columns = [:name,  :gender, :checklist ] config.columns[:gender].form_ui = :radio config.columns[:gender].options[:options] = [['Male', [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=121&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Suppose you have a field in your table, which accepts array of values through multiple checkboxes, then here is a way to show these checkboxes on your active scaffold create/update form.</p>
<p><span style="color:#800000;">#Controller</span></p>
<p><span style="color:#800000;">class UsersController &lt; ApplicationController</span><br />
<span style="color:#800000;"> active_scaffold :user do |config|</span><br />
<span style="color:#800000;"> config.label = “Users”</span><br />
<span style="color:#800000;"> config.columns = [:name,  :gender, :checklist ]</span><br />
<span style="color:#800000;"> config.columns[:gender].form_ui = :radio</span><br />
<span style="color:#800000;"> config.columns[:gender].options[:options] = [['Male', '1'], ['Female','2']]</span><br />
<span style="color:#800000;"> end</span><br />
<span style="color:#800000;"> end</span></p>
<p><span style="color:#333333;">Assume &#8216;checklist&#8217; is the column which accepts an array of values, then add the below chunk of code to your users helper</span></p>
<p><span style="color:#800000;">#Users helper</span></p>
<p><span style="color:#800000;">module UsersHelper</span><br />
<span style="color:#800000;"> def checklist_form_column(record, options)</span><br />
<span style="color:#800000;"> html = &#8216; &#8216;</span><br />
<span style="color:#800000;"> (1..5).each do |val|</span><br />
<span style="color:#800000;"> html &lt;&lt; check_box_tag(&#8220;record[checklist][]&#8220;, val, :id =&gt; &#8220;check_#{val}&#8221;)</span><br />
<span style="color:#800000;"> html &lt;&lt; &#8220;&lt;label for=&#8217;check_#{val}&#8217;&gt;&#8221;</span><br />
<span style="color:#800000;"> html &lt;&lt; &#8220;lable_#{val}&#8221;</span><br />
<span style="color:#800000;"> html &lt;&lt; &#8220;&lt;/label&gt;&#8221;</span><br />
<span style="color:#800000;"> html &lt;&lt; &#8220;&lt;br/&gt;&#8221;</span><br />
<span style="color:#800000;"> end</span><br />
<span style="color:#800000;"> html</span><br />
<span style="color:#800000;"> end</span><br />
<span style="color:#800000;">end</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subhashmohan.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subhashmohan.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subhashmohan.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subhashmohan.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subhashmohan.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subhashmohan.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subhashmohan.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subhashmohan.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subhashmohan.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subhashmohan.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subhashmohan.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subhashmohan.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subhashmohan.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subhashmohan.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=121&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subhashmohan.wordpress.com/2010/11/18/active-scaffold-add-checkbox-array-for-a-particular-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/575a464594e162c206b292eecdb00430?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Subhash Mohan</media:title>
		</media:content>
	</item>
		<item>
		<title>Active Scaffold : Add radio buttons to your form</title>
		<link>http://subhashmohan.wordpress.com/2010/11/18/active-scaffold-add-radio-buttons-to-your-form/</link>
		<comments>http://subhashmohan.wordpress.com/2010/11/18/active-scaffold-add-radio-buttons-to-your-form/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 12:47:43 +0000</pubDate>
		<dc:creator>Subhash Mohan</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[active scaffold]]></category>

		<guid isPermaLink="false">http://subhashmohan.wordpress.com/?p=112</guid>
		<description><![CDATA[The way to add radio buttons to your active scaffold create/update from is as shown below #Controller class UsersController &#60; ApplicationController active_scaffold :user do &#124;config&#124; config.label = &#8220;Users&#8221; config.columns = [:name, :gender] config.columns[:gender].form_ui = :radio config.columns[:gender].options[:options] = [['Male', '1'], ['Female','2']] end end<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=112&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The way to add radio buttons to your active scaffold create/update from is as shown below</p>
<p><span style="color:#800000;">#Controller</span></p>
<p><span style="color:#800000;">class UsersController &lt; ApplicationController</span><br />
<span style="color:#800000;"> active_scaffold :user do |config|</span><br />
<span style="color:#800000;"> config.label = &#8220;Users&#8221;</span><br />
<span style="color:#800000;"> config.columns = [:name, :gender]</span><br />
<span style="color:#800000;"> config.columns[:gender].form_ui = :radio</span><br />
<span style="color:#800000;"> config.columns[:gender].options[:options] = [['Male', '1'], ['Female','2']]</span><br />
<span style="color:#800000;"> end</span><br />
<span style="color:#800000;"> end</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subhashmohan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subhashmohan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subhashmohan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subhashmohan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subhashmohan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subhashmohan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subhashmohan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subhashmohan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subhashmohan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subhashmohan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subhashmohan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subhashmohan.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subhashmohan.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subhashmohan.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=112&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subhashmohan.wordpress.com/2010/11/18/active-scaffold-add-radio-buttons-to-your-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/575a464594e162c206b292eecdb00430?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Subhash Mohan</media:title>
		</media:content>
	</item>
		<item>
		<title>Caching in Rails with memcached</title>
		<link>http://subhashmohan.wordpress.com/2010/03/27/caching-in-rails-with-memcached/</link>
		<comments>http://subhashmohan.wordpress.com/2010/03/27/caching-in-rails-with-memcached/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 18:10:54 +0000</pubDate>
		<dc:creator>Subhash Mohan</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://subhashmohan.wordpress.com/?p=91</guid>
		<description><![CDATA[Installation 1. Follow this link to download and install memcached. 2. Start the memcached server using either memcached -vv or /etc/init.d/memcached start Integrating memcached with your rails application. 1. Install memcache-client gem install memcache-client 2. Add the below line to  end of your config/environment.rb file. CACHE = MemCache.new('127.0.0.1') 3. Add the following method to your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=91&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><strong>Installation</strong></p>
<p style="padding-left:30px;">1. Follow this <a href="http://dag.wieers.com/rpm/packages/memcached/" target="_blank">link</a> to download and install memcached.<br />
2. Start the memcached server using either</p>
<pre style="text-align:justify;padding-left:30px;"><span style="color:#800000;">memcached -vv</span></pre>
<p style="text-align:justify;padding-left:30px;">or</p>
<pre style="text-align:justify;padding-left:30px;"><span style="color:#800000;">/etc/init.d/memcached start</span></pre>
<p style="text-align:justify;"><strong> Integrating memcached with your rails application.</strong></p>
<p style="text-align:justify;padding-left:30px;">1. Install memcache-client</p>
<pre style="text-align:justify;padding-left:30px;"><span style="color:#800000;">gem install memcache-client</span></pre>
<p style="text-align:justify;padding-left:30px;">2. Add the below line to  end of your config/environment.rb file.</p>
<pre style="text-align:justify;padding-left:30px;"><span style="color:#800000;">CACHE = MemCache.new('127.0.0.1')</span></pre>
<p style="text-align:justify;padding-left:30px;">3. Add the following method to your application controller / application  helper or where ever you want according to your need.</p>
<pre style="padding-left:30px;text-align:justify;"><span style="color:#800000;">def perform_cache(key)
  begin
   unless output = CACHE.get(key)
     output = yield
     CACHE.set(key, output, 15.minutes)
   end
 rescue =&gt; e
  logger.info “MEMCACHE ERROR++++++++++++++++++++++++++++++++++++”
  logger.info “ERROR : #{e.message}”
  logger.info “MEMCACHE ERROR++++++++++++++++++++++++++++++++++++”
  output = yield
  end
  return output
 end</span></pre>
<p style="padding-left:30px;">The above method performs the caching based on a unique key. If the  value for that key already exists, it will return the output from the  stored cache or  else it will execute the block you are using when  calling the above method and generate a new value from the executed  block for the particular key and store it in the cache.</p>
<p style="padding-left:30px;">You can set a timer to expire the cached data.(15 mins in my case.)</p>
<p style="padding-left:30px;">If you don’t want to expire the cache based on timer, simply remove the  third parameter we are passing to ’set’ method.</p>
<p style="padding-left:30px;">The above method also handles the exception,in case your memcache server  is down for some reason.</p>
<p style="padding-left:30px;">4.  Cache your complex queries/methods as follows.</p>
<pre style="padding-left:30px;"><span style="color:#800000;">my_key =  Digest::MD5.hexdigest(request.request_uri)
output = perform_cache(my_key) { ClassName.method_name(…) }
</span></pre>
<p style="padding-left:30px;">Note : The key generated should be always unique, otherwise it will overwrite your existing cached data already having the same key. I am using the URL as  the key, Since the URL is pretty long we can take the MD5 hash/SHA1 hash of it and  use it as the key.</p>
<p style="padding-left:30px;">5.  You can edit memory  used by memcached as follows.</p>
<pre style="padding-left:30px;"><span style="color:#800000;">Open /etc/sysconfig/memcached file and edit “CACHESIZE” entry,
this entry is in MBs.</span>

That's it your ready to go.</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subhashmohan.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subhashmohan.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subhashmohan.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subhashmohan.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subhashmohan.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subhashmohan.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subhashmohan.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subhashmohan.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subhashmohan.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subhashmohan.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subhashmohan.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subhashmohan.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subhashmohan.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subhashmohan.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=91&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subhashmohan.wordpress.com/2010/03/27/caching-in-rails-with-memcached/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/575a464594e162c206b292eecdb00430?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Subhash Mohan</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails crontab with &#8220;whenever&#8221; gem</title>
		<link>http://subhashmohan.wordpress.com/2010/03/27/rails-crontab-with-whenever-gem/</link>
		<comments>http://subhashmohan.wordpress.com/2010/03/27/rails-crontab-with-whenever-gem/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 05:35:40 +0000</pubDate>
		<dc:creator>Subhash Mohan</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://subhashmohan.wordpress.com/?p=45</guid>
		<description><![CDATA[Introduction gem “whenever“  provides you with the valid cronjob syntax and also writes / updates the crontab file for you. Installation 1.  Install the gem gem install whenever 2. Add below line to your config/environment.rb config.gem &#8216;whenever&#8217;, :lib=&#62;false, :source=&#62;&#8217;http://gemcutter.org&#8217; 3.  Go to your application root directory and run the below command wheneverize .   This [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=45&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#333333;">Introduction</span></p>
<p><span style="color:#333333;">gem “whenever“  provides you with the valid cronjob syntax and also writes / updates the crontab file for you.</span></p>
<p><span style="color:#333333;">Installation</span></p>
<p><span style="color:#333333;">1.  Install the gem</span></p>
<p><strong><span style="color:#800000;"> </span></strong><span style="color:#800000;">gem install whenever</span></p>
<p><span style="color:#333333;">2. Add below line to your config/environment.rb</span></p>
<p><span style="color:#333333;"> <span style="color:#800000;">config.gem &#8216;whenever&#8217;, :lib=&gt;false, :source=&gt;&#8217;http://gemcutter.org&#8217;</span><br />
</span></p>
<p><span style="color:#333333;">3.  Go to your application root directory and run the below command</span></p>
<p><span style="color:#800000;">wheneverize .</span></p>
<p><span style="color:#800000;"> </span></p>
<pre><span style="color:#800000;"><strong> </strong></span>  This will create a “config/schedule.rb” file for you.

  EXAMPLE “config/schedule.rb”

 <span style="color:#000000;"> set :environment, :development

  set :path, "/var/www/MyApp"

  # Scheduled Hourly

   every 4.hours do
   command "/usr/bin/your_command"
   end

  # Scheduled Daily

   every 1.day, :at =&gt; '12:00 am' do
   runner "MyModel.yourmethod"
   end

   # Scheduled Weekly

   every :monday, :at =&gt; '11:00 pm' do
   rake   "your:rake:task"
   end
</span><span style="color:#800000;"><strong><span style="color:#000000;">
</span></strong></span></pre>
<p><span style="color:#800000;"><strong><span style="color:#000000;"> </span></strong></span>Consider the above as the contents of your config/schedule.rb file.</p>
<p><span style="color:#333333;">4.  Now from application root directory, run the below command</span></p>
<p><span style="color:#800000;">whenever</span></p>
<p><strong><span style="color:#800000;"> </span></strong></p>
<p><span style="color:#333333;">The above command will output valid syntax for the crontab as below.</span></p>
<pre> <span style="color:#800000;">0 0 * * * /var/www/MyApp/script/runner -e development “Model.your_method”</span>

 <span style="color:#800000;">0 0,4,8,12,16,20 * * * /usr/bin/your_command

 </span><span style="color:#800000;">0 23 * * 1 cd /var/www/MyApp &amp;&amp; RAILS_ENV=development /usr/bin/env rake your:rake_task</span>
<span style="color:#800000;"><strong><span style="color:#000000;"> </span></strong></span></pre>
<p><span style="color:#333333;">5. Now, To write the above content in your Crontab file run the below command.</span></p>
<p><span style="color:#800000;">whenever –update-crontab</span></p>
<p><span style="color:#800000;"> </span></p>
<p><span style="color:#333333;">you can see the above entries in your crontab file by running “crontab -e”.</span></p>
<p><span style="color:#333333;">That&#8217;s it, you are ready to go.</span></p>
<pre><span style="color:#800000;"> </span></pre>
<p><span style="color:#800000;"> </span></p>
<pre><span style="color:#800000;"><strong>

</strong></span></pre>
<p><strong><br />
</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subhashmohan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subhashmohan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subhashmohan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subhashmohan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subhashmohan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subhashmohan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subhashmohan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subhashmohan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subhashmohan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subhashmohan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subhashmohan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subhashmohan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subhashmohan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subhashmohan.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=45&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subhashmohan.wordpress.com/2010/03/27/rails-crontab-with-whenever-gem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/575a464594e162c206b292eecdb00430?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Subhash Mohan</media:title>
		</media:content>
	</item>
		<item>
		<title>Edge Rails</title>
		<link>http://subhashmohan.wordpress.com/2009/06/29/edge-rails/</link>
		<comments>http://subhashmohan.wordpress.com/2009/06/29/edge-rails/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 13:50:17 +0000</pubDate>
		<dc:creator>Subhash Mohan</dc:creator>
				<category><![CDATA[Edge Rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://subhashmohan.wordpress.com/?p=16</guid>
		<description><![CDATA[Before you get to know how to install and use Edge Rails, you need to know what actually Edge Rails is. Edge Rails actually means running a local developmental version of rails. It&#8217;s an alternative to gem rails. Many a times I have thought how to freeze my rails application to local gems version or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=16&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#808080;"><strong>Before you get to know how to install and use Edge Rails, you need to know what actually Edge Rails is.</strong></span></p>
<p><span style="color:#808080;"><strong>Edge Rails actually means running a local developmental version of rails. It&#8217;s an alternative to gem rails.</strong></span></p>
<p><span style="color:#808080;"><strong>Many a times I have thought how to freeze my rails application to local gems version or a particular gems version, So that I can run my frozen application on some other system which have some different version of rails installed. Luckily I found Edge Rails.<br />
</strong></span></p>
<p><span style="color:#808080;">For example:- Consider you have frozen your rails application to the latest rails version 2.3.2 and you want to run this application on a different system which have a much older version of rails, consider for example version 2.1.0.</span></p>
<p><span style="color:#808080;">In this case you can run your newest frozen version of rails application on  other system, which have an older version of rails installed, without any glitches or bugs, using Edge Rails.</span></p>
<h2><span style="color:#808080;">How to Install and Use Edge Rails?</span></h2>
<p><span style="color:#808080;"><strong>1.  If you want to freeze your application to the gems version currently available on your system, then go to root of your rails application and run</strong></span></p>
<p><span style="color:#800000;"><em><strong>rake rails:freeze:gems</strong></em></span></p>
<p><span style="color:#808080;"><strong>By running the above command a new directory “rails” will be created inside your vendors directory. When you run your rails framework, Your application will first check for this directory and if it&#8217;s present, Rails components will be loaded from this directory instead of using your system copy of rails, and thus you are switched from Gems Rails to Edge Rails.</strong></span></p>
<p><span style="color:#808080;"><strong>2.  If at any point of time, you want to switch back from Edge Rails to Gem Rails. You can always do it by running the below command</strong></span></p>
<p><strong><em><span style="color:#800000;">rake rails:unfreeze</span></em></strong></p>
<p><span style="color:#808080;"><strong>3. </strong><strong> If you want to freeze your application to the latest development version, then run.</strong></span></p>
<p><em><span style="color:#800000;"><strong>rake rails:freeze:edge</strong></span></em></p>
<p><span style="color:#808080;"><strong>once you are switched to the latest development version, your javascripts and other configuration files needs to be updated corresponding to the latest version. For this you need to run,</strong></span></p>
<p><span style="color:#800000;"><em><strong>rake rails:update</strong></em></span></p>
<p><span style="color:#808080;"><strong> 4. Freeze your application to a different version.<br />
Consider you want to freeze your rails application to rails version 2.1.0, then you have to just run the command</strong></span></p>
<p><em><span style="color:#800000;"><strong>rake rails:freeze:edge RELEASE=2.1.0</strong></span></em></p>
<p><strong><span style="color:#800000;"> </span><span style="color:#808080;">5. In order to find out what version of rails your application uses, From the  root of your rails application, run</span></strong></p>
<p><span style="color:#800000;"><strong>script/about</strong></span></p>
<p><span style="color:#808080;">your output will be something like below.</span></p>
<p><span style="color:#808080;">About your application&#8217;s environment<br />
Ruby version              1.8.6 (i686-linux)<br />
RubyGems version          1.1.1<br />
Rails version             2.1.0<br />
Active Record version     2.1.0<br />
Action Pack version       2.1.0<br />
Active Resource version   2.1.0<br />
Action Mailer version     2.1.0<br />
Active Support version    2.1.0<br />
Edge Rails revision       unknown<br />
Application root          your application path<br />
Environment               development<br />
Database adapter          mysql<br />
Database schema version   20090622125330<br />
Loaded suite script/about<br />
Started</span></p>
<p><span style="color:#808080;">Finished in 0.000606 seconds.</span></p>
<p><span style="color:#808080;">0 tests, 0 assertions, 0 failures, 0 errors</span></p>
<p><span style="color:#808080;"><strong>6. Installing all other application depending gems locally.</strong></span></p>
<p><span style="color:#808080;"><strong> 1. Consider your application require the following two gems</strong></span></p>
<p><span style="color:#808080;"><strong>a) will_paginate<br />
b) mini_magick</strong></span></p>
<p><span style="color:#808080;"><strong> Now go to your config/environment.rb file and config the required gems  as  below.</strong></span></p>
<p><span style="color:#808080;"><strong>Rails::Initializer.run do |config|<br />
config.gem “mini_magick”<br />
config.gem “will_paginate”<br />
end</strong></span></p>
<p><span style="color:#808080;"><strong> 2. Now consider these gems are not yet installed in your local machine. In order to install the above gems in your local machine,  from the root of your application run</strong></span></p>
<p><span style="color:#800000;"><em><strong>rake gems:install</strong></em></span></p>
<p><span style="color:#808080;"><strong>If you have already installed the above gems at some point of time, then skip this step and proceed to next step.</strong></span></p>
<p><span style="color:#808080;"><strong> 3. Now In order to make the above gems application-dependent rather than system-dependent gems. You need to unpack all these gems inside your application using</strong></span></p>
<p><span style="color:#800000;"><em><strong>rake gems:unpack</strong></em></span></p>
<p><span style="color:#808080;"><strong>The above command will create a new directory “gems” inside your vendor folder and unpack the two gems “will_paginate” and “mini_magick” inside the “gems” directory.</strong></span></p>
<p><span style="color:#808080;"><strong> 4. Unpack gems individually</strong></span></p>
<p><span style="color:#808080;"><strong> There are two ways to unpack the gems individually.</strong></span></p>
<p><span style="color:#808080;"><strong> Either run this from the root of your application.</strong></span></p>
<p><strong> <span style="color:#800000;"><em> rake gems:unpack GEM=will_paginate</em></span></strong></p>
<p><span style="color:#333333;"><strong><em> <span style="color:#808080;">or</span></em></strong></span></p>
<p><span style="color:#808080;"><strong><em> </em>change your directory to /vendor/gems and run</strong></span></p>
<p><strong> <em><span style="color:#800000;">gem unpack “gem_name”</span></em></strong></p>
<p><!-- 		@page { size: 8.5in 11in; margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:513px;width:1px;height:1px;">4. Freeze your application to a different version.</p>
<p>Consider you want to freeze your rails application to rails version 2.1.0, then you have to just run the command</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subhashmohan.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subhashmohan.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subhashmohan.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subhashmohan.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subhashmohan.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subhashmohan.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subhashmohan.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subhashmohan.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subhashmohan.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subhashmohan.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subhashmohan.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subhashmohan.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subhashmohan.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subhashmohan.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=16&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subhashmohan.wordpress.com/2009/06/29/edge-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/575a464594e162c206b292eecdb00430?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Subhash Mohan</media:title>
		</media:content>
	</item>
		<item>
		<title>Implementing Bibit Payment for Rails Applications</title>
		<link>http://subhashmohan.wordpress.com/2009/06/23/implementing-bibit-payment-for-rails-applications/</link>
		<comments>http://subhashmohan.wordpress.com/2009/06/23/implementing-bibit-payment-for-rails-applications/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 17:40:34 +0000</pubDate>
		<dc:creator>Subhash Mohan</dc:creator>
				<category><![CDATA[Payment Methodology]]></category>
		<category><![CDATA[bibit]]></category>
		<category><![CDATA[payment methods]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://subhashmohan.wordpress.com/?p=4</guid>
		<description><![CDATA[Every one in the Ruby / Rails world knows and implements different payment methodologies for their E-commerce shopping cart. We understand people know much about how to integrate with Paypal, Authorize.net…blah blah blah… however the biggest issue with all these payment gateways is that the customers have to be associated with multiple websites i.e. If [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=4&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Every one in the Ruby / Rails world knows and implements different payment methodologies for their E-commerce shopping cart. We understand people know much about how to integrate with Paypal, Authorize.net…blah blah blah… however the biggest issue with all these payment gateways is that the customers have to be associated with multiple websites i.e. If I want to buy something from a cart which associates to Paypal gateway, I need to have an account. So if that is the case then for every different Ecommerce payment gateway I need to have a separate account and I need to remember the credentials. Also many times if I want to implement offline payments such as money orders or cheque, etc., we don’t have any implementation that could take care of this system.</p>
<p>However many time I wished that it would be good that these shopping companies support multiple payment gateways and also multiple methods which are country oriented. E.g. Paypal is not an acceptable method in India, where as it is a Hit in US… Same way In France JCB is well known and in UK, Diners club, switch, maestro cards are well known. So I always believe that I should be allowed to pick up only the ones I need to make the payments as most of the time I shall be associated to one of them rather than getting myself associated to every one and forget at the end of the day where what transaction took place.</p>
<p>Thankfully to my support came in <strong>Bibit</strong>, a payment service of <strong>Royal Bank of Scotland (RBS)</strong> which supports almost all the payment gateways available and provides you information of gateways based on the country of the shopper. And to my advantage, I was supposed to write a code for a shopping cart to which it supported. Bibit is very much well known in Europe. Bibit also support Multi-Lingual</p>
<p>Before I start telling you how to implement bibit, a small introduction about BIBIT</p>
<p><em><strong>“The Bibit Redirect, or Select, service model is an integration method to the Bibit Payment Service suited for Internet shop environments, call centers or reservation centers, and multi-channel sales situations. It allows for real-time processing of payments and ensures a maximum number of up-to-date payment methods. The Redirect model is secure, provides Bibit with required information to perform active fraud risk assessment, and is the fastest way to get up and running with on-line payments.”</strong></em> – As available in bibit website.</p>
<p>More details can be found in <a href="http://www.bibit.com/">http://www.bibit.com</a> . Also this post picks up much of the information from the bibit document and has been modified to suit Ruby on Rails users.</p>
<p>What bibit does is, it provides a standard methodology to the shopping cart websites who can register with Bibit and then run their code with bibit. Once the shopping websites provide bibit some information the control is transferred to Bibit and after completion just like paypal, you can take back the control.  So actually the shopping Cart websites integrate their systems with bibit and bibit provides the customers of the shopping cart websites with various predefined payment gateways based on the country and languages.</p>
<p>Now we know what Bibit is, Lets to see how we can integrate bibit to our shopping carts.</p>
<p>Bibit provides an exclusive method called<strong> XML Order Creation </strong>which can be utilized to send information to bibit’s website as a secured channel and they handle the rest. The data is sent as an XML with some key elements such as description, amount, orderContent, paymentMethodMask and shopper.</p>
<p>Some of the Elements of this XML are as follows</p>
<p><strong>1. Document Type      Declarations</strong></p>
<p>As with any XML declaration we need to declare bibit as well to use the standards payment service dtd as follows</p>
<p>&lt;?xml version=”1.0″?&gt;</p>
<p>&lt;!DOCTYPE paymentService PUBLIC “-//Bibit//DTD Bibit PaymentService v1//EN”</p>
<p>“http://dtd.bibit.com/paymentService_v1.dtd”&gt;</p>
<p><strong>2. Merchant Information</strong></p>
<p><strong> </strong></p>
<p>This is the information that the shopping cart have to provide to bibit in order to authorize the input XML. The main information required is the merchant code.</p>
<p>&lt;paymentService version=”1.4″ merchantCode=”MYMERCHANTCODE”&gt;</p>
<p>&lt;submit&gt;</p>
<p>&lt;/submit&gt;</p>
<p>&lt;/paymentService&gt;</p>
<p>The XML requires only the Merchant code, however in order to send the xml to the bibit website we need the merchant code as login and the xml password to send this XML. This is more explained in the Http Connectivity section</p>
<p><strong>3.  Order Creation      Details</strong></p>
<p>While creating an order we have to follow few significant methods so that Bibit understands the order that has been sent. Some of them are</p>
<p>a.  <strong><span style="text-decoration:underline;">Order       Description</span></strong><span style="text-decoration:underline;"> </span>– Requires Order Code, Description, Order       value, Currency in which order is being placed and the decimal place. The       below is a sample example of an order. The Order Code has to be very much       unique from bibit’s perspective and hence it is advisable to create the       ordercode with a Salt of your’s and a number</p>
<p>&lt;order orderCode=”T0211011″&gt;</p>
<p>&lt;description&gt;Some description of your product&lt;/description&gt;</p>
<p>&lt;amount value=”2600″ currencyCode=”USD” exponent=”2″/&gt;</p>
<p>…</p>
<p>&lt;/order&gt;</p>
<p>b.  <strong><span style="text-decoration:underline;">Order       Content</span></strong> – Has the complete details of the order and its line       items. These details are wrapped inside a CDATA to allow bibit to confirm       / show the user the order details. This is something like giving the       details of what you would ideally put in a Confirm page before you place       the order.</p>
<p>&lt;orderContent&gt;</p>
<p>&lt;![CDATA[content here]]&gt;</p>
<p>&lt;/orderContent&gt;</p>
<p>Some of the information that is generally part of order content are order code, line items, item price, total amount, shipping and billing addresses, merchant contact details, etc., For more information you can refer to bibit’s documentation.</p>
<p>c.  <strong><span style="text-decoration:underline;">Selecting       Payment Gateways </span></strong>– In bibit, you can select which all payment       gateways that you can allow to your client to login and support.</p>
<p>&lt;paymentMethodMask&gt;</p>
<p>&lt;include code=”ALL”/&gt;</p>
<p>&lt;include code=”VISA-SSL”/&gt;</p>
<p>&lt;exclude code=”AMEX-SSL”/&gt;</p>
<p>&lt;/paymentMethodMask&gt;</p>
<p>d.  <strong><span style="text-decoration:underline;">Email       address</span> </strong>– Finally we need to give the shopper’s email       address as follows</p>
<p>&lt;shopper&gt;</p>
<p>&lt;shopperEmailAddress&gt;shopper@myshopper.com&lt;/shopperEmailAddress&gt;</p>
<p>&lt;/shopper&gt;</p>
<p>4.  <strong>XML Validation</strong></p>
<p>Finally it is a good practice to have a XML validation done on your xml. Bibit is quite strict about xml format and the transaction might fail for this activity.</p>
<p>So once you have the XML ready, it should look as below</p>
<p>&lt;?xml version=”1.0″?&gt;</p>
<p>&lt;!DOCTYPE paymentService PUBLIC “-//Bibit/DTD Bibit PaymentService v1//EN”</p>
<p>“http://dtd.bibit.com/paymentService_v1.dtd”&gt;</p>
<p>&lt;paymentService version=”1.4″ merchantCode=”MYMERCHANT”&gt;</p>
<p>&lt;submit&gt;</p>
<p>&lt;order orderCode=”T0211011″&gt;</p>
<p>&lt;description&gt;20 tulip bulbs from MYMERCHANT Webshops&lt;/description&gt;</p>
<p>&lt;amount value=”2600″ currencyCode=”EUR” exponent=”2″/&gt;</p>
<p>&lt;orderContent&gt;</p>
<p>&lt;![CDATA[</p>
<p>&lt;center&gt;&lt;table&gt;</p>
<p>&lt;tr&gt;&lt;td bgcolor="#ffff00"&gt;Your Internet Order:&lt;/td&gt;&lt;td colspan="2"</p>
<p>bgcolor="#ffff00" align="right"&gt;T0211011&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td bgcolor="#ffff00"&gt;Description:&lt;/td&gt;&lt;td&gt;20 Tulip bulbs&lt;/td&gt;&lt;td</p>
<p>align="right"&gt;1,00&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="2"&gt;Subtotal:&lt;/td&gt;&lt;td align="right"&gt;20,00&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="2"&gt;VAT: 15%&lt;/td&gt;&lt;td align="right"&gt;3,00&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="2"&gt;Shipping and Handling:&lt;/td&gt;&lt;td align="right"&gt;3,00&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="2" bgcolor="#c0c0c0"&gt;Total cost:&lt;/td&gt;&lt;td bgcolor="#c0c0c0"</p>
<p>align="right"&gt;Euro 26,00&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="3"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td bgcolor="#ffff00" colspan="3"&gt;Your billing address:&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="3"&gt;Mr. J. Shopper,&lt;br&gt;11 Shopperstreet,&lt;br&gt;1234</p>
<p>Shoppercity,&lt;br&gt;Netherlands&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="3"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td bgcolor="#ffff00" colspan="3"&gt;Your shipping address:&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="3"&gt;Mr.J. Shopper,&lt;br&gt;11 Shopperstreet,&lt;br&gt;1234</p>
<p>Shoppercity,&lt;br&gt;Netherlands&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="3"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td bgcolor="#ffff00" colspan="3"&gt;Our contact information:&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="3"&gt;MYMERCHANT Webshops International,&lt;br&gt;461 Merchant</p>
<p>Street,&lt;br&gt;1255 Merchanttown,&lt;br&gt;Netherlands</p>
<p>&lt;br&gt;&lt;br&gt;mymerchant@webshops.int&lt;br&gt;(111) 1235 456&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="3"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td bgcolor="#c0c0c0" colspan="3"&gt;Billing notice:&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan="3"&gt;Your payment will be handled by Bibit Global Payments</p>
<p>Services&lt;br&gt;This name may appear on your bank</p>
<p>statement&lt;br&gt;http://www.bibit.com&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;/table&gt;&lt;/center&gt;</p>
<p>]]&gt;</p>
<p>&lt;/orderContent&gt;</p>
<p>&lt;paymentMethodMask&gt;</p>
<p>&lt;include code=”VISA-SSL”/&gt;</p>
<p>&lt;include code=”AMEX-SSL”/&gt;</p>
<p>&lt;include code=”ECMC-SSL”/&gt;</p>
<p>&lt;/paymentMethodMask&gt;</p>
<p>&lt;shopper&gt;</p>
<p>&lt;shopperEmailAddress&gt;jshopper@myprovider.int&lt;/shopperEmailAddress&gt;</p>
<p>&lt;/shopper&gt;</p>
<p>&lt;shippingAddress&gt;</p>
<p>&lt;address&gt;</p>
<p>&lt;firstName&gt;John&lt;/firstName&gt;</p>
<p>&lt;lastName&gt;Shopper&lt;/lastName&gt;</p>
<p>&lt;street&gt;11 Shopperstreet&lt;/street&gt;</p>
<p>&lt;postalCode&gt;1234&lt;/postalCode&gt;</p>
<p>&lt;city&gt;Shoppercity&lt;/city&gt;</p>
<p>&lt;countryCode&gt;NL&lt;/countryCode&gt;</p>
<p>&lt;telephoneNumber&gt;0123456789&lt;/telephoneNumber&gt;</p>
<p>&lt;/address&gt;</p>
<p>&lt;/shippingAddress&gt;</p>
<p>&lt;/order&gt;</p>
<p>&lt;/submit&gt;</p>
<p>&lt;/paymentService&gt;</p>
<p>What Next, now lets do some Ruby coding to send this XML to bibit and do the processing. We shall utilize <strong>Net HTTP</strong> for the same. So in your controller i.e. where you have checkout processing being done you can add this code. I shall call my controller as <strong>CartController </strong>and the code shall be in <strong>cart_controller.rb</strong></p>
<p>The first thing I require is to declare the required lib files. We need to declare http, https and uri classes. These are available as follows</p>
<p>require ‘net/https’</p>
<p>require ‘net/http’</p>
<p>require ‘uri’</p>
<p>Once you have your declaration ready all you have to do is write the code in the make_payment  method</p>
<p>def make_payment</p>
<p>#….write all the necessary code.to do necessary bibit payments<br />
end</p>
<p>Lets understand one by one on what has to be filled with in the make_payment method</p>
<p><strong>First get the XML ready </strong></p>
<p><strong> </strong></p>
<p>xml_string = %{xml as above}</p>
<p>It is better to putin the xml with in the %{} as the content becomes a well formatted xml. If we try to do it as quotes or double quotes, lots of escape sequences have to be used which is a pain. We found out sing %{} is the best method.</p>
<p><strong>Once your XML is ready, Start posting the XML throught NET HTTP</strong></p>
<p>All you need for this to work, is connection to the bibit service, your merchant code and the merchant password that you have declared in bibit.com using your login credentials.</p>
<p>url = URI.parse(”https://secure-test.bibit.com/jsp/merchant/xml/paymentService.jsp”)</p>
<p>@http=Net::HTTP.new(url.host, url.port)</p>
<p>@http.use_ssl = true</p>
<p>@http.start(){|http|</p>
<p>req = Net::HTTP::Post.new(url.path)</p>
<p>req.basic_auth MYMERCHANTCODE, MYXMLPASSWORD</p>
<p>req['Content-Type'] = ‘text/xml’</p>
<p>req.body = xml_string # as seen above</p>
<p>response = http.request(req)</p>
<p>response_xml = response.body</p>
<p>return response_xml</p>
<p>}</p>
<p>The URL you see is for the bibit’s test environment, All you have to do is to change the url to https://secure-test.bibit.com/jsp/merchant/xml/paymentService.jsp.</p>
<p><strong>Handling the Response </strong></p>
<p>Once you send the XML to the bibit as above, bibit shall send you back an response XML which gives you some information about bibit accepting your order. All we have to do is to extract the order code and the re-direction information from response xml and re-direct our application to bibit to do the complete gateway process</p>
<p>&lt;?xml version=”1.0″?&gt;</p>
<p>&lt;!DOCTYPE paymentService PUBLIC “-//Bibit//DTD Bibit PaymentService v1//EN”</p>
<p>“http://dtd.bibit.com/paymentService_v1.dtd”&gt;</p>
<p>&lt;paymentService merchantCode=”MYMERCHANTCODE” version=”1.4″&gt;</p>
<p>&lt;reply&gt;</p>
<p>&lt;orderStatus orderCode=”T0211011″&gt;</p>
<p>&lt;reference id=”1234567″&gt;</p>
<p>https://secure-test.bibit.com/jsp/shopper/SelectPaymentMethod.jsp?orderKey=</p>
<p>MYMERCHANT^T0211011</p>
<p>&lt;/reference&gt;</p>
<p>&lt;/orderStatus&gt;</p>
<p>&lt;/reply&gt;</p>
<p>&lt;/paymentService&gt;</p>
<p>All that is important in this xml is</p>
<p><strong><span style="text-decoration:underline;">Order URL</span></strong><span style="text-decoration:underline;"> </span>– This is the URL that has to be redirected to allow bibit to complete the payments. The url in the xml is</p>
<p>https://secure.bibit.com/jsp/shoppe/SelectPaymentMethod.jsp?orderKey=</p>
<p>MYMERCHANT^T0211011</p>
<p><strong><span style="text-decoration:underline;">Reference ID </span></strong>– This ID is more necessary for Future references or offline payments so that you know the status of the product. The reference ID in this xml response is</p>
<p>1234567</p>
<p><strong><span style="text-decoration:underline;">Order Code</span></strong> – This is the code that we generated before sending it to the bibit payment. This has to be unique and can be used to check in the database for order  placement. The order code in the xml response is</p>
<p>T0211011</p>
<p>In order to extract the information from the response xml we can use any parser such as ReXML parser / Atom Parser / CobraVsMongoose</p>
<p><strong>Redirecting to Bibit </strong></p>
<p>Once the URL has been acquired from the response XML, do a redirection to Bibit. Also you can do additional activities so that you can change the look and feel and information in the website.</p>
<p><strong>a.</strong><strong> <span style="text-decoration:underline;">Redirecting URLs</span></strong></p>
<p>Additionally you can customize the URL to send your success / failure / pending URLs to Bibit to redirect to your website so that you can handle the particular order status i.e. When the Bibit completes the payment and if you want them to redirect back to your website (similar to returnurl of paypal), you can provide them as encoded text along with the bibit url (available in the response xml). The procedure could be as follows</p>
<p>&amp;successURL=CGI::escape(url_for(:controller=&gt;”cart”, :action=&gt;”success”)</p>
<p>&amp;pendingURL=CGI::escape(url_for(:controller=&gt;”cart”, :action=&gt;”pending”)</p>
<p>&amp;failureURL=CGI::escape(url_for(:controller=&gt;”cart”, :action=&gt;”failure”)</p>
<p><a href="https://secure.bibit.com/jsp/shopper/SelectPaymentMethod.jsp?orderKey=MYMERCHANTCODE%5eT0211011&amp;successURL=http%3A%2F%2Fyour_domain.com%2Fcart%2Fsuccess&amp;failureURL=http%3A%2F%2Fyour_domain.com%2Fcart%2Ffailure&amp;pendingURL=http%3A%2F%2Fyour_domain.com%2Fcart%2Fpending">https://secure.bibit.com/jsp/shopper/SelectPaymentMethod.jsp?orderKey=MYMERCHANTCODE^T0211011&amp;successURL=http%3A%2F%2Fyour_domain.com%2Fcart%2Fsuccess&amp;failureURL=http%3A%2F%2Fyour_domain.com%2Fcart%2Ffailure&amp;pendingURL=http%3A%2F%2Fyour_domain.com%2Fcart%2Fpending</a></p>
<p>You are at your disposable to implement any of these. Bibit shall redirect to your URLs along with the order code so that you can handle if you want to convert the cart into an order or not. A sample Success URL that bibit creates is as follows</p>
<p><a href="http://www.your_domain.com/cart/success?orderKey=MYADMINCODE%5eMYMERCHANTCODE%5eT0211010&amp;paymentStatus=AUTHORISED&amp;paymentAmount=2600&amp;paymentCurrency=USD&amp;mac=0083c47880f0533d773c350ee0d51cfc">http://www.your_domain.com/cart/success?orderKey=MYADMINCODE^MYMERCHANTCODE^T0211010&amp;paymentStatus=AUTHORISED&amp;paymentAmount=2600&amp;paymentCurrency=USD&amp;mac=0083c47880f0533d773c350ee0d51cfc</a></p>
<p><strong>b. </strong><strong> <span style="text-decoration:underline;">Setting Country and Language Codes</span></strong></p>
<p>You can also set bibit the country code and the language code in order to allow bibit to show the payment methodologies for particular country and the bibit originating text based on language. This is again sent as part of the bibit url. Example URL is as follows<br />
<a href="https://secure.bibit.com/jsp/shopper/SelectPaymentMethod.jsp?orderKey=MYMERCHANTCODE%5eT0211011&amp;country=GB&amp;language=en">https://secure.bibit.com/jsp/shopper/SelectPaymentMethod.jsp?orderKey=MYMERCHANTCODE^T0211011&amp;country=GB&amp;language=en</a></p>
<p><strong>c. </strong><strong><span style="text-decoration:underline;">Setting User Interface of Bibit Payment Service</span></strong></p>
<p>You can also send font / body attributes to allow bibit show information in the way you want. E.g.</p>
<p><a href="https://secure.bibit.com/jsp/shopper/SelectPaymentMethod.jsp?orderKey=MYMERCHANTCODE%5eT0211011&amp;bodyAttr=bgcolor%3D%22black%22&amp;fontAttr=face%3D%22arial%22+color%3D%22white%252">https://secure.bibit.com/jsp/shopper/SelectPaymentMethod.jsp?orderKey=MYMERCHANTCODE^T0211011&amp;bodyAttr=bgcolor%3D%22black%22&amp;fontAttr=face%3D%22arial%22+color%3D%22white%2</a></p>
<p>Hope this information helps you to start understanding and handle payments for your websites. We say three cheers to Bibit to help us solve a big problem.</p>
<p>Let me know your comments or if you need any support implementing Bibit Payments for your website.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subhashmohan.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subhashmohan.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subhashmohan.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subhashmohan.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subhashmohan.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subhashmohan.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subhashmohan.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subhashmohan.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subhashmohan.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subhashmohan.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subhashmohan.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subhashmohan.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subhashmohan.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subhashmohan.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subhashmohan.wordpress.com&amp;blog=8293815&amp;post=4&amp;subd=subhashmohan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subhashmohan.wordpress.com/2009/06/23/implementing-bibit-payment-for-rails-applications/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/575a464594e162c206b292eecdb00430?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Subhash Mohan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
