<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Spritle's Blog</title>
	
	<link>http://www.spritle.com/blogs</link>
	<description>Distributed Agile Software Development</description>
	<lastBuildDate>Fri, 17 Feb 2012 09:58:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Spritle" /><feedburner:info uri="spritle" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Run HighCharts in RhoMobile (iPhone, iPad and Android)</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/V73ihNVIWAg/</link>
		<comments>http://www.spritle.com/blogs/2012/02/17/run-highcharts-in-rhomobile-iphone-ipad-and-android/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 09:58:52 +0000</pubDate>
		<dc:creator>Vinothini B</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[highcharts]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[rhodes]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=1501</guid>
		<description><![CDATA[I like HighCharts and used it for one of our project. I wanted to use HighCharts in Rhomobile mobile applications and thought I would give it a whirl. You can find the sample I tried that would include Stacked bar chart Combination chart Line time series chart Pie chart Before we jump in, HighCharts will [...]]]></description>
			<content:encoded><![CDATA[<p>I like HighCharts and used it for one of our project. I wanted to use HighCharts in Rhomobile mobile applications and thought I would give it a whirl.<br />
You can find the sample I tried that would include </p>
<ul>
<li>Stacked bar chart</li>
<li>Combination chart</li>
<li>Line time series chart</li>
<li>Pie chart</li>
</ul>
<p><span id="more-1501"></span><br />
Before we jump in, HighCharts will work fine in Android OS 3+ and iPhone/iPad.<br />
It won&#8217;t work in Android 2.x versions (as per my knowledge and also see <a href="http://www.highcharts.com/documentation/compatibility" target="_blank">http://www.highcharts.com/documentation/compatibility</a>)</p>
<h4>You can find the source code of the demo at <a target="_blank" href="https://github.com/spritle/rhodes_highcharts_demo"> https://github.com/spritle/rhodes_highcharts_demo </a> </h4>
<p><strong>How to use:</strong><br />
1) You need to include the JavaScript file (highchart.js) in the head section of the web page.<br />
2) In the Script tag in the Head tag of the web page or in a separate .js file, add the JavaScript code to initialize the chart. Note that the <strong>id</strong> of the <strong>div</strong> where you want to place the chart is given in the renderTo option below:</p>
<pre class="brush: javascript">
var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: &#039;container&#039;,
						defaultSeriesType: &#039;bar&#039;
					},
					title: {
						text: &#039;Stacked bar chart&#039;,
						margin: 18
					},
					xAxis: {
						categories: [&#039;Apples&#039;, &#039;Oranges&#039;, &#039;Pears&#039;, &#039;Grapes&#039;, &#039;Bananas&#039;]
					},
					subtitle: {
						text: &#039;&lt;a href=&quot;http://www.spritle.com/&quot;&gt; HighCharts in Rhomobile - Demo 1 &lt;br/&gt; by Spritle Software &lt;/a&gt;&#039;,
						style: {
							color: &#039;#FF00FF&#039;,
							fontWeight: &#039;bold&#039;
						}
					},
					yAxis: {
						min: 0,
						title: {
							text: &#039;Total fruit consumption&#039;
						}
					},
					legend: {
						backgroundColor: &#039;#FFFFFF&#039;,
						reversed: true
					},
					tooltip: {
						formatter: function() {
							return &#039;&#039;+
								 this.series.name +&#039;: &#039;+ this.y +&#039;&#039;;
						}
					},
					plotOptions: {
						series: {
							stacking: &#039;normal&#039;
						}
					},
				        series: [{
						name: &#039;John&#039;,
						data: [3, 1, 2, 3, 2]
					}, {
						name: &#039;Jane&#039;,
						data: [2, 2, 3, 2, 1]
					}, {
						name: &#039;Joe&#039;,
						data: [2, 3, 1, 2, 3]
					}]
				});

			});
</pre>
<pre class="brush: javascript">
 //note the &quot;id&quot; is very important
 &lt;div id=&quot;container&quot; style=&quot;height: 80%;margin: 0 auto&quot;&gt;&lt;/div&gt;
</pre>
<p>Thanks and please share your comments.<br />
<b>Sample screenshots from Android simulator: </b><br />
<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/index.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/index-237x300.png" alt="" width="237" height="300" class="alignnone size-medium wp-image-1505" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/stacked_bar_chart.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/stacked_bar_chart-237x300.png" alt="" width="237" height="300" class="alignnone size-medium wp-image-1514" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/combination_chart.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/combination_chart-237x300.png" alt="" width="237" height="300" class="alignnone size-medium wp-image-1519" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/line_time_chart.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/line_time_chart-237x300.png" alt="" width="237" height="300" class="alignnone size-medium wp-image-1520" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/pie_chart.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/pie_chart-237x300.png" alt="" width="237" height="300" class="alignnone size-medium wp-image-1521" /></a></p>
<p><b>Sample screenshots from iPhone simulator: </b><br />
<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_index2.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_index2-159x300.png" alt="" width="159" height="300" class="alignnone size-medium wp-image-1510" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_stacked_bar_chart1.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_stacked_bar_chart1-159x300.png" alt="" width="159" height="300" class="alignnone size-medium wp-image-1527" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_combination_chart.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_combination_chart-159x300.png" alt="" width="159" height="300" class="alignnone size-medium wp-image-1530" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_line_time_series_chart.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_line_time_series_chart-159x300.png" alt="" width="159" height="300" class="alignnone size-medium wp-image-1531" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_pie_chart1.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/iphone_pie_chart1-159x300.png" alt="" width="159" height="300" class="alignnone size-medium wp-image-1533" /></a></p>
<p><b>Sample screenshots from iPad simulator: </b><br />
<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/ipad_stacked_bar_chart.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/ipad_stacked_bar_chart-231x300.png" alt="" width="231" height="300" class="alignnone size-medium wp-image-1538" /></a>&nbsp;&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/ipad_combination.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/ipad_combination-232x300.png" alt="" width="232" height="300" class="alignnone size-medium wp-image-1539" /></a>&nbsp;&nbsp;&nbsp;<br />
<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/ipad_pie_chart.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/ipad_pie_chart-233x300.png" alt="" width="233" height="300" class="alignnone size-medium wp-image-1540" /></a></p>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=1501&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/V73ihNVIWAg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2012/02/17/run-highcharts-in-rhomobile-iphone-ipad-and-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2012/02/17/run-highcharts-in-rhomobile-iphone-ipad-and-android/</feedburner:origLink></item>
		<item>
		<title>Configure Awstats Apache Params to Show Valid URI in Typo3</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/E2HNQp6QbfE/</link>
		<comments>http://www.spritle.com/blogs/2012/02/16/configure-awstats-apache-params-to-show-valid-uri/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 04:54:18 +0000</pubDate>
		<dc:creator>Sivakumar V</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Typo3]]></category>
		<category><![CDATA[Apache2]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=1269</guid>
		<description><![CDATA[Here is the quick tip to configure awstats in Typo3. This will enable Top 25 section to show valid URI. In general it will show link as ([path][title] &#8211;[uid]) format, but lets try to show full URI. All you need to do is: Configure Apache page names as show below config.stat = 1 config.stat_apache = [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the quick tip to configure awstats in Typo3. This will enable Top 25 section to show valid URI.<br />
In general it will show link as ([path][title] &#8211;[uid]) format, but lets try to show full URI.<br />
<span id="more-1269"></span></p>
<p>All you need to do is:<br />
Configure Apache page names as show below</p>
<pre class="brush: php">
config.stat = 1
config.stat_apache = 1
config.stat_apache_logfile = awstatslog_typo3.log
config.stat_apache_pagenames = [request_uri]
</pre>
<p>Please place this in template setup.</p>
<p>Hope you liked it.</p>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=1269&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/E2HNQp6QbfE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2012/02/16/configure-awstats-apache-params-to-show-valid-uri/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2012/02/16/configure-awstats-apache-params-to-show-valid-uri/</feedburner:origLink></item>
		<item>
		<title>Scrollable Content with Fixed Header and Footer – Rhomobile App</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/kYtaZKG15hA/</link>
		<comments>http://www.spritle.com/blogs/2012/02/13/scrollable-content-with-fixed-header-and-footer-rhomobile-app/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 12:39:04 +0000</pubDate>
		<dc:creator>Vinothini B</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[rhodes]]></category>
		<category><![CDATA[rhomobile]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=1456</guid>
		<description><![CDATA[While using Rhomobile, often you might want to create an app that would have scrollable content with fixed header and footer, horizontally scrollable content, vertically scrollable content, scrollable content with a specific div and so on. Here is a sample app that got all this integrated together for you. The sample app contains the source [...]]]></description>
			<content:encoded><![CDATA[<p>While using Rhomobile, often you might want to create an app that would have scrollable content with fixed header and footer, horizontally scrollable content, vertically scrollable content, scrollable content with a specific div and so on. Here is a sample app that got all this integrated together for you.<span id="more-1456"></span></p>
<p>The sample app contains the source code that would have </p>
<ul>
<li>Vertical iScroll</li>
<li>Horizontal iScroll</li>
<li>Carousel iScroll</li>
<li>iScroll inside a fixed-height Div</li>
</ul>
<h4>You can find the source code at <a target="_blank" href="https://github.com/spritle/rhodes_iscroll_sample">https://github.com/spritle/rhodes_iscroll_sample</a></h4>
<p>I believe the important piece of code is at https://github.com/spritle/rhodes_iscroll_sample/blob/master/app/Iscroll/custom_iscroll.erb </p>
<pre class="brush: javascript">
var myScroll;

function loaded() {
  // specify the id of the div that contains the content
  myScroll = new iScroll(&#039;wrapper&#039;, { scrollbarClass: &#039;myScrollbar&#039; });

}
// set touchmove to false
document.addEventListener(&#039;touchmove&#039;, function (e) { e.preventDefault(); }, false);
document.addEventListener(&#039;DOMContentLoaded&#039;, loaded, false);
</pre>
<p><b>Here is some sample screenshots from Android: </b><br />
<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/mainpage.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/mainpage.png" alt="" width="240" height="320" class="alignnone size-full wp-image-1466" /></a>&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/vertical_scroll.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/vertical_scroll.png" alt="" width="240" height="320" class="alignnone size-full wp-image-1466" /></a>&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/horizontal_scroll.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/horizontal_scroll.png" alt="" width="240" height="320" class="alignnone size-full wp-image-1466" /></a>&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/carousel_scroll.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/carousel_scroll.png" alt="" width="240" height="320" class="alignnone size-full wp-image-1466" /></a>&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/fixed_height_div.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/fixed_height_div.png" alt="" width="240" height="320" class="alignnone size-full wp-image-1466" /></a></p>
<p><b>Here is some sample screenshots from iPhone simulator: </b><br />
<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/mainpage1.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/mainpage1.png" alt="" width="159" height="300" class="alignnone size-full wp-image-1475" /></a>&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/vertical.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/vertical.png" alt="" width="159" height="300" class="alignnone size-full wp-image-1475" /></a>&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/horizontal.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/horizontal.png" alt="" width="159" height="300" class="alignnone size-full wp-image-1475" /></a>&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/carousel_scroll1.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/carousel_scroll1.png" alt="" width="159" height="300" class="alignnone size-full wp-image-1475" /></a>&nbsp;&nbsp;<a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/fixed_height_div_scroll.png"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/fixed_height_div_scroll.png" alt="" width="159" height="300" class="alignnone size-full wp-image-1475" /></a></p>
<p>Please add your comment if you got some questions or suggestions.</p>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=1456&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/kYtaZKG15hA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2012/02/13/scrollable-content-with-fixed-header-and-footer-rhomobile-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2012/02/13/scrollable-content-with-fixed-header-and-footer-rhomobile-app/</feedburner:origLink></item>
		<item>
		<title>Facebook Application with Rails</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/esXp9f34NUc/</link>
		<comments>http://www.spritle.com/blogs/2012/02/08/facebook-canvas-app-using-ruby-on-rails/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 00:08:44 +0000</pubDate>
		<dc:creator>Dhepthi L Narasimhan</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook-sdk]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=1400</guid>
		<description><![CDATA[I tried to integrate ruby on rails app in Facebook. Developing facebook app is quite easy to with rails and Javascript sdk. The documentation for Facebook Javascript sdk is easy to implement in rails app. Here the steps to develop facebook app using rails, First we need to create an app in Facebook developer site [...]]]></description>
			<content:encoded><![CDATA[<p>I tried to integrate ruby on rails app in Facebook. Developing facebook app is quite easy to with rails and Javascript sdk. The documentation for Facebook <a href="https://developers.facebook.com/docs/reference/javascript/" target="_blank">Javascript sdk</a> is easy to implement in rails app. <span id="more-1400"></span></p>
<p>Here the steps to develop facebook app using rails, First we need to create an app in Facebook developer site as shown in the image</p>
<p><a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-5.09.34-PM.jpg"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-5.09.34-PM.jpg" alt="" title="Screen shot 2012-02-06 at 5.09.34 PM" width="380" height="180" class="aligncenter size-full wp-image-1409" /></a></p>
<p>App will be created with unique App ID and Application Secret. You will use these values in rails app. Now on another side, we will create an sample rails app using scaffold as</p>
<pre class="brush: ruby">
rails new blog
cd blog
rails generate scaffold Post name:string title:string content:text
</pre>
<p>Now let us make some changes to integrate facebook with this rails app. Create yaml file in config/facebook.yml with the following contents</p>
<pre class="brush: ruby">
development: &amp;defaults
  client_id: YOUR_APP_ID
  client_secret: YOUR_APP_SECRET
  scope: user_about_me,user_activities,user_birthday,user_education_history,
         user_events,user_groups,user_hometown,user_interests,user_likes
  canvas_url: http://apps.facebook.com/UserBookmarks/
test:
  &lt;&lt;: *defaults
production:
  &lt;&lt;: *defaults
</pre>
<p>Once these changes are done, run you rails app and find your system ip address. Let&#8217;s assume your rails app is running in <strong>http://192.168.1.103:3000/</strong>, use this url to integrate with facebook app. Going back to Facebook app in Developers page, enable <strong>Website</strong> and <strong>App on Facebook </strong>and give your rails app running url as shown below</p>
<p><a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-3.46.27-PM.jpg"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-3.46.27-PM.jpg" alt="" title="Screen shot 2012-02-06 at 3.46.27 PM" width="380" height="200" class="aligncenter size-full wp-image-1409"/></a></p>
<p>Save the changes and search your App(ex: UserBookmarks) in Facebook, your facebook app running using rails will be loaded inside the canvas page as shown below</p>
<p><a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-3.52.24-PM.jpg"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-3.52.24-PM.jpg" alt="" title="Screen shot 2012-02-06 at 3.52.24 PM" width="380" height="200" class="aligncenter size-full wp-image-1409" /></a></p>
<p>Now in the above image, you will be seeing facebook logout, share and send request links. I used Facebook Javascript sdk to communicate with facebook api. In order to use that in your app, you need to edit your erb file. I have changed my application.html.erb file as follows</p>
<p>First you have to load all.js based on the locale as</p>
<pre class="brush: ruby">
&lt;script src=&quot;http://connect.facebook.net/en_US/all.js&quot;&gt;&lt;/script&gt;
</pre>
<p>Then, load the SDK synchronously which may be useful for debugging with your app_id as</p>
<pre class="brush: ruby">
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
    FB.init({
         appId: YOUR_APP_ID,
         xfbml: true,
        cookie: true,
        oauth: true
       });

&lt;/script&gt;
</pre>
<p>Then, create a div with id as <strong>fb-root </strong>and create facebook login button as</p>
<pre class="brush: ruby">
&lt;div id=&quot;fb-root&quot;&gt;
&lt;fb:login-button autologoutlink=&quot;true&quot; onlogin=&quot;OnRequestPermission();&quot; scope=&quot;user_about_me,user_activities,user_birthday,user_online_presence&quot;&gt;
&lt;/fb:login-button&gt;
&lt;div &gt;
</pre>
<p>The above will create the Facebook login button and wil change to logout button once it is connected. While logging, it will request you for permission as below</p>
<p><a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-5.21.42-PM.jpg"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-5.21.42-PM.jpg" alt="" title="Screen shot 2012-02-06 at 5.21.42 PM" width="380" height="200" class="aligncenter size-full wp-image-1409" /></a></p>
<p>You can use other api like app_request and sharing the info in post. You can send app request to your friends as shown</p>
<pre class="brush: ruby">
&lt;%= link_to &#039;Send Request to your friends&#039;, &#039;#&#039;, :id =&gt; :app_request %&gt;

&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;

 $(&#039;#app_request&#039;).click(function () {
    FB.ui({
      method: &#039;apprequests&#039;,
      message: &#039;Hi This is my test app developed in RoR and integrated in FB&#039;,
      data: &#039;Stores important links of user&#039;
    });
return false;
  });

&lt;/script&gt;
</pre>
<p>Similarly the sample code to post your feed in facebook is as below</p>
<pre class="brush: ruby">
&lt;%= link_to &#039;Share your experience&#039;, &#039;#&#039;, :id =&gt; :post_comments %&gt;

$(&#039;#post_comments&#039;).click(function () {

        // calling the API ...
        var obj = {
          method: &#039;feed&#039;,
          link: &#039;http://apps.facebook.com/265171790218414/&#039;,
          picture: &#039;http://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/256x256/User1.png&#039;,
          name: &#039;User Bookmark App&#039;,
          caption: &#039;Using RoR and FaceBook&#039;,
          description: &#039;Integrated RoR app in Facebook through canvas&#039;
        };
        FB.ui(obj);
       return false;
      });
</pre>
<p>Now when we click send request link in your app, you can see all your friends as shown</p>
<p><a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-5.04.19-PM.jpg"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-5.04.19-PM.jpg" alt="" title="Screen shot 2012-02-06 at 5.04.19 PM" width="380" height="200" class="aligncenter size-full wp-image-1409" /></a></p>
<p>As well as Share your experience link will render a popup as</p>
<p><a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-5.07.36-PM.jpg"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-5.07.36-PM.jpg" alt="" title="Screen shot 2012-02-06 at 5.07.36 PM" width="380" height="200" class="aligncenter size-full wp-image-1409" /></a></p>
<p>I have deployed this app in Heroku and replace the Url in FaceBook app as</p>
<p><a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-3.08.20-PM.jpg"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-3.08.20-PM.jpg" alt="" title="Screen shot 2012-02-06 at 3.08.20 PM" width="380" height="200" class="aligncenter size-full wp-image-1409" /></a></p>
<p>Also specify the app domain in Facebook app as</p>
<p><a href="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-3.09.06-PM.jpg"><img src="http://www.spritle.com/blogs/wp-content/uploads/2012/02/Screen-shot-2012-02-06-at-3.09.06-PM.jpg" alt="" title="Screen shot 2012-02-06 at 3.09.06 PM" width="380" height="200" class="aligncenter size-full wp-image-1409" /></a></p>
<p>I hope this blog will be useful for developing a facebook app using rails. The sample source code can be found at https://github.com/Dhepthi/User-History. Please feel free to improve and send me a pull request.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=1400&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/esXp9f34NUc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2012/02/08/facebook-canvas-app-using-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2012/02/08/facebook-canvas-app-using-ruby-on-rails/</feedburner:origLink></item>
		<item>
		<title>Push Notifications in Rhodes using Ruby</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/8ytEsR5F1zw/</link>
		<comments>http://www.spritle.com/blogs/2012/01/20/push-notifications-in-rhodes-using-ruby/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 11:55:19 +0000</pubDate>
		<dc:creator>Surendran Sukumaran</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=1368</guid>
		<description><![CDATA[I tried Push notifications concept in Rhodes using Rhoconnect and its works well. The documentation for the same is also nice. For one of my project there was no need for Rhoconnect and so I wanted to get Push Notification done using Ruby (without Rhoconnect). Here is the sample code I tried. Create a simple [...]]]></description>
			<content:encoded><![CDATA[<p>I tried Push notifications concept in Rhodes using Rhoconnect and its works well. The  <a href="http://rhomobile.com/" title="Rhomobile" target="_blank">documentation</a> for the same is also nice.<br />
For one of my project there was no need for Rhoconnect and so I wanted to get Push Notification done using Ruby (without Rhoconnect). Here is the sample code I tried.<span id="more-1368"></span><br />
Create a simple Rhodes app using <b>rhodes app app_name</b></p>
<ul>
<li>
<strong>Step 1 :</strong><br />
     Enable push by adding it in <strong>build.yml</strong> file under capablities.</p>
<pre class="brush: ruby">
	capablities:
	  - push
</pre>
</li>
<li>
<strong>Step 2:</strong><br />
Add the registered emailid c2dm_registered@gmail.com under the android section in <strong>build.yml</strong> file</p>
<pre class="brush: ruby">
	android
	  - push
	     - email : c2dm_registered@gmail.com
</pre>
</li>
<li>
<strong>Step 3:</strong><br />
Find the registeration id or device id (device id registered to receive push Notification for this particular app)</p>
<pre class="brush: ruby">
    System.get(&#039;device_id&#039;) # =&gt; A12A13123wiu13-erughyiug3
</pre>
<p>Which returns a long string, this is the registration id which we will be using to send a push notification to the actual mobile device (Warning &#8220;it wont work with Emulators).
</li>
<li>
<strong>Step 4:</strong><br />
Handle what should be done when we receive a Push Notification<br />
Set a handler at app/application.rb </p>
<pre class="brush: ruby">
    System.get_push_notification &quot;/app/Push/receive_push&quot;, &quot;params to be passed&quot;
</pre>
</li>
<li>
<strong>Step 5:</strong><br />
Implement the action receive_push.<br />
So whenever the Device App receive&#8217;s a Notification the &#8220;receive_push&#8221; method will be called.<br />
<script src="https://gist.github.com/1646300.js?file=push.rb"></script>
</li>
</ul>
<p>The platform I have chosen is <strong>Android devices</strong>. </p>
<blockquote><p>
Note : You should be registered with Google C2DM with your gmail id in the URL(http://code.google.com/android/c2dm/signup.html) by which you can Send and Receive Push Notifications.<br />
  You will be receving an email from the Google team after registration.<br />
  Push works with Android 2.2 or greater versions.</p></blockquote>
<p>That&#8217;s it. Everything is set so far and now the device is ready to receive Push Notifications. <img src='http://www.spritle.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Now the important part is to send the push notification messages from our server side using ruby code.<br />
I used sepeedy_c2dm ruby client for the same.<br />
Please see the sample code implementation below<br />
<script src="https://gist.github.com/1646309.js?file=ruby_push_notification.rb"></script></p>
<p>Lets run it all together.<br />
<strong>When you execute this Ruby code, the device should call the &#8220;receive_push&#8221; method.</strong></p>
<p>Hurdles I faced while trying Push.<br />
1) Device mismatchID<br />
When there is a mismatch in the email id registred with C2DM in the server side and the mobile(client) side, the server will throw error saying devicemismathcid.<br />
2) If you forget to add push under the capablities, the System.get(&#8220;device_id&#8221;) will return an empty string or nil value.<br />
3) If the api (google android version 2.2+) is not properly installed, it may thrown an error.</p>
<p>Thanks to Rhomobile team for making my life easier with the Push Notifications from the Rhoconnect perspective.</p>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=1368&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/8ytEsR5F1zw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2012/01/20/push-notifications-in-rhodes-using-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2012/01/20/push-notifications-in-rhodes-using-ruby/</feedburner:origLink></item>
		<item>
		<title>Rhodes 3.3.x Supports Motorola Rhoelements and Android ET1</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/R01af3E6y60/</link>
		<comments>http://www.spritle.com/blogs/2012/01/04/rhodes-3-3-x-supports-motorola-rhoelements-and-android-et1/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 12:32:32 +0000</pubDate>
		<dc:creator>Sivakumar V</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[Android ET1]]></category>
		<category><![CDATA[rhodes]]></category>
		<category><![CDATA[rhomobile]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=1361</guid>
		<description><![CDATA[Rhodes team recently released 3.3.1 version which got support for RhoElements (Motorola Windows Mobile sdk with device specific features) and also for Android ET1. The sample app &#8220;Barcode for Motorola devices&#8221; looks interesting and we started trying that out. The other recent feature is WebKit browser for Motorola devices. We planning to try that as [...]]]></description>
			<content:encoded><![CDATA[<p>Rhodes team recently released 3.3.1 version which got support for RhoElements (Motorola Windows Mobile sdk with device specific features) and also for Android ET1.<br />
<span id="more-1361"></span></p>
<p>The sample app &#8220;<a href="http://docs.rhomobile.com/rhodes/device-caps#barcode-for-motorola-devices">Barcode for Motorola devices</a>&#8221; looks interesting and we started trying that out.</p>
<p>The other recent feature is <a href="http://docs.rhomobile.com/rhodes/device-caps#webkit-browser-for-motorola-devices">WebKit browser for Motorola devices</a>. We planning to try that as well using Windows Mobile Emulator.</p>
<p>Rhomobile team also released the <a href="https://rubygems.org/gems/rhoelements">rhoelements</a> gem (gem install rhoelements &#8212; pre). We just skimmed through the source to understand it further. We will try to write a blog about it as well.</p>
<p>Here is the release notes for Rhodes 3.3.1 from Rhomobile team.</p>
<ul>
<li> Integration with RhoElements v2 to suppport Motorola devices
<li> Add Ruby Encoding constants
<li> MapView improvements on all platforms
<li> Android: support SDK 4.0 and NDK r7
<li> iPad2: fix camera issue
<li> Contacts: add filter parameters for iPhone and Android
<li> Support update RhoBundle on iPhone and Windows Mobile
<li> Blackberry: support multiple simulators with one JDE
<li> Blackberry: support JQueryMobile on Blackberry 6 and later with full browser mode </ul>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=1361&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/R01af3E6y60" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2012/01/04/rhodes-3-3-x-supports-motorola-rhoelements-and-android-et1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2012/01/04/rhodes-3-3-x-supports-motorola-rhoelements-and-android-et1/</feedburner:origLink></item>
		<item>
		<title>Consume SOAP Service from RhoMobile (iPhone, Android, WM and so on) apps</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/lmBQaDnHyE8/</link>
		<comments>http://www.spritle.com/blogs/2011/12/26/consume-soap-service-from-rhomobile-iphone-android-wm-and-so-on-apps/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 11:31:12 +0000</pubDate>
		<dc:creator>Balaji D Loganathan</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[rhomobile]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[WM]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=1353</guid>
		<description><![CDATA[We wanted to consume simple SOAP based web services from the iPhone, Android applications using RhoMobile framework. We dont want to use Savon as it got too much dependency to become rhodes-ruby extension. Just thought lets write the raw soap client without using SOAP gems. Rhodes already support net-http and rexml(rhoxml) for such tasks. The [...]]]></description>
			<content:encoded><![CDATA[<p>We wanted to consume simple SOAP based web services from the iPhone, Android applications using RhoMobile framework. We dont want to use Savon as it got too much dependency to become rhodes-ruby extension.<br />
Just thought lets write the raw soap client without using SOAP gems. Rhodes already support net-http and rexml(rhoxml) for such tasks.<br />
<span id="more-1353"></span><br />
The sample source code can be found at <a href="https://github.com/spritle/rhodes_soap_test/blob/master/app/Soap/soap_controller.rb" target="_blank">https://github.com/spritle/rhodes_soap_test/blob/master/app/Soap/soap_controller.rb</a> which basically consume the SOAP services from http://www.w3schools.com/webservices/tempconvert.asmx</p>
<p>The basic steps involve on the controller side involves:</p>
<ol>
<li>Initialize the http object with soap service url
<pre class="brush: ruby">
      http = Net::HTTP.new(&#039;www.w3schools.com&#039;, 80)
      path = &#039;/webservices/tempconvert.asmx&#039; </pre>
</li>
<li>Create the SOAP Request envelope
<pre class="brush: ruby">
data = &lt;&lt;-EOF
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;SOAP-ENV:Envelope
xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
SOAP-ENV:encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;
&lt;SOAP-ENV:Body&gt;
  &lt;CelsiusToFahrenheit xmlns=&quot;http://tempuri.org/&quot;&gt;
        &lt;Celsius&gt;#{celsius}&lt;/Celsius&gt;
  &lt;/CelsiusToFahrenheit&gt;
&lt;/SOAP-ENV:Body&gt;
&lt;/SOAP-ENV:Envelope&gt;
EOF
</pre>
</li>
<li>Set Headers if required
<pre class="brush: ruby">
headers = {
        &#039;Content-Type&#039; =&gt; &#039;text/xml&#039;,
        &#039;Host&#039; =&gt; &#039;spritle.com&#039;
      }
</pre>
</li>
<li>Make the http request and then process the result data
<pre class="brush: ruby">
resp, data = http.post(path, data, headers)
puts data
</pre>
</li>
<li>Sample SOAP Response
<pre class="brush: ruby">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&lt;soap:Body&gt;&lt;CelsiusToFahrenheitResponse xmlns=&quot;http://tempuri.org/&quot;&gt;&lt;CelsiusToFahrenheitResult&gt;89.6&lt;/CelsiusToFahrenheitResult&gt;&lt;/CelsiusToFahrenheitResponse&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;
</pre>
</li>
</ol>
<p>If you want you can also the process the SOAP Response string using XML parsers like rhoxml.<br />
Example:</p>
<pre class="brush: ruby">
xmldoc = REXML::Document.new(data)
xmldoc.elements.each(&quot;soap:Envelope/soap:Body/CelsiusToFahrenheitResponse/CelsiusToFahrenheitResult&quot;) { |e| puts e.text
}
</pre>
<p>If you want to see how we can use savon as rhodes-ruby-extensions, please leave us a comment so that we can share our code on Github.</p>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=1353&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/lmBQaDnHyE8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2011/12/26/consume-soap-service-from-rhomobile-iphone-android-wm-and-so-on-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2011/12/26/consume-soap-service-from-rhomobile-iphone-android-wm-and-so-on-apps/</feedburner:origLink></item>
		<item>
		<title>Ruby Tips 11: Install mysql gem on Mac OS X Lion</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/uXEs7gSj9t0/</link>
		<comments>http://www.spritle.com/blogs/2011/11/11/ruby-tips-11-install-mysql-gem-on-mac-os-x-lion/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 11:52:46 +0000</pubDate>
		<dc:creator>Balaji D Loganathan</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Distributed Agile]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=1347</guid>
		<description><![CDATA[brew install mysql Is you have installed mysql server already and have a failed mysql gem, then remove the mysql server first [ see] Do this to install mysql system tables: mysql_install_db --verbose --user=`whoami` --basedir=&#34;$(brew --prefix mysql)&#34; --datadir=/usr/local/var/mysql --tmpdir=/tmp Install mysql gem: sudo env ARCHFLAGS=&#34;-arch x86_64&#34; gem install mysql -- --with-mysql-dir=/usr/local/Cellar/mysql --with-mysql-lib=/usr/local/Cellar/mysql/5.5.15/lib/ --with-mysql-include=/usr/local/mysql/5.5.15/include --with-mysql-config=/usr/local/Cellar/mysql/5.5.15/bin/mysql_config To [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: php">brew install mysql</pre>
<p>Is you have installed mysql server already and have a failed mysql gem, then remove the mysql server first [ <a href="http://akrabat.com/computing/uninstalling-mysql-on-mac-os-x-leopard/" target="_blank">see</a>]</p>
<p>Do this to install mysql system tables:</p>
<pre class="brush: php">
mysql_install_db --verbose --user=`whoami` --basedir=&quot;$(brew --prefix mysql)&quot; --datadir=/usr/local/var/mysql --tmpdir=/tmp
</pre>
<p>Install mysql gem:</p>
<pre class="brush: php">
sudo env ARCHFLAGS=&quot;-arch x86_64&quot; gem install mysql -- --with-mysql-dir=/usr/local/Cellar/mysql --with-mysql-lib=/usr/local/Cellar/mysql/5.5.15/lib/ --with-mysql-include=/usr/local/mysql/5.5.15/include  --with-mysql-config=/usr/local/Cellar/mysql/5.5.15/bin/mysql_config
</pre>
<p>To find out what your machine is. use <strong>uname -a</strong></p>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=1347&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/uXEs7gSj9t0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2011/11/11/ruby-tips-11-install-mysql-gem-on-mac-os-x-lion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2011/11/11/ruby-tips-11-install-mysql-gem-on-mac-os-x-lion/</feedburner:origLink></item>
		<item>
		<title>Rails Application with Authentication and Authorization</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/DHa9jMnh4wc/</link>
		<comments>http://www.spritle.com/blogs/2011/10/28/rails-application-with-authentication-and-authorization/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 05:00:09 +0000</pubDate>
		<dc:creator>Vamsi Krishna</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=476</guid>
		<description><![CDATA[This is a small blog about applying authorization to an application and how to write unit,functional and integration tests for the application in the end, so the first blog I will cover how to do simple authorization in rails and in the second part of the application I will write the complete test cases for [...]]]></description>
			<content:encoded><![CDATA[<p>This is a small blog about applying authorization to an application and how to write unit,functional and integration tests for the application in the end, so the first blog I will cover how to do simple authorization in rails and in the second part of the application I will write the complete test cases for this application.</p>
<p>The scenario: Application &#8211; Managing Contents<br />
(list of actions available are index,show,new,create,edit,update and destroy)<br />
The application has three roles Admin,Publisher and member</p>
<p>Admin &#8211; has access to all the actions.<br />
Publisher &#8211; has access to everything except destroy action.<br />
member &#8211; can only access index page and show page.</p>
<p>There are so many plugins available outside for implementing this Authorization. I decided to do it on my own since this is a simple authorization application, but if you want to go for complex scenarios I suggest you check this <a href="http://steffenbartsch.com/blog/2008/08/rails-authorization-plugins/">link</a> </p>
<p>Ok enough talk, let&#8217;s digg inside the code.</p>
<p>This application is completely about Authorization, I provided a simple authentication but, for providing proper authentication the plugins I suggest are auth_logic or restful_authentication(plugins) or you can write your own authentication code. Anyway let&#8217;s go with the code.</p>
<p>In this application I created login_controller for authentication, it&#8217;s a simple form with one textfield which will expect you to enter the user type(member,publisher or admin).</p>
<p>To access any action first of all the user must be a registered user that is member, Admin can access every action of the application and Publisher can do everything except deleting the content.</p>
<p>Let me show the code for authentication</p>
<p>So I created a scaffold for content application.</p>
<p>So once you successfully logged in the the role will be saved in a session.</p>
<p>So the code is self explanatory, you can move this to application controller if you want to applay this authorization than to more than one controller.</p>
<p>admin?.publisher? are can be used a helpers in the views to hide the links for users that are not supposed to show</p>
<p>for example:</p>
<pre class="brush: ruby">
&lt;% if publisher? || admin? %&gt;
    &lt;td&gt;&lt;%= link_to &#039;Edit&#039;, edit_content_path(content) %&gt;&lt;/td&gt;
    &lt;% end %&gt;
    &lt;% if admin?
    &lt;td&gt;&lt;%= link_to &#039;Destroy&#039;, content, :confirm =&gt; &#039;Are you sure?&#039;, :method =&gt; :delete %&gt;&lt;/td&gt;
    &lt;% end %&gt;
</pre>
<p>    So this is the simple authorization I provide for the system, if your system is complex there are plugins available for authorization you can check this blog post for that </p>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=476&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/DHa9jMnh4wc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2011/10/28/rails-application-with-authentication-and-authorization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2011/10/28/rails-application-with-authentication-and-authorization/</feedburner:origLink></item>
		<item>
		<title>Ruby Tips 10: Using Devise Gem for API Token Authentication</title>
		<link>http://feedproxy.google.com/~r/Spritle/~3/iWBaGROQkq8/</link>
		<comments>http://www.spritle.com/blogs/2011/10/12/ruby-tips-10-using-devise-gem-for-api-token-authentication/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 05:18:02 +0000</pubDate>
		<dc:creator>Surendran Sukumaran</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[devise]]></category>
		<category><![CDATA[Distributed Agile]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://www.spritle.com/blogs/?p=1325</guid>
		<description><![CDATA[Ok. If you have already read the Devise gem wiki, you wouldn&#8217;t be seeing this, if not here is the simple way to do it. Go to devise.rb and set # If true, authentication through token does not store user in session and needs # to be supplied on each request. Useful if you are [...]]]></description>
			<content:encoded><![CDATA[<p>Ok. If you have already read the Devise gem wiki, you wouldn&#8217;t be seeing this, if not here is the simple way to do it.<br />
<span id="more-1325"></span><br />
Go to devise.rb and set </p>
<pre class="brush: ruby">
  # If true, authentication through token does not store user in session and needs
  # to be supplied on each request. Useful if you are using the token as API token.
  config.stateless_token = true
</pre>
<p>Now, have a RESTFul method that would look like</p>
<pre class="brush: ruby">
  def get_authentication_token
    user = User.find_by_email(params[:user][:email])
    password = params[:user][:password]
    if user &amp;&amp; user.encrypted_password == BCrypt::Engine.hash_secret(password, user.encrypted_password)
      status = true
      ## do something with user object
    else
      render_json(false, &quot;Invalid login or password.&quot;, 401)
    end
  end
</pre>
<img src="http://www.spritle.com/blogs/wp-content/plugins/pixelstats/trackingpixel.php?post_id=1325&amp;ts=1329472755" style="display:none;" alt="pixelstats trackingpixel"/><img src="http://feeds.feedburner.com/~r/Spritle/~4/iWBaGROQkq8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.spritle.com/blogs/2011/10/12/ruby-tips-10-using-devise-gem-for-api-token-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.spritle.com/blogs/2011/10/12/ruby-tips-10-using-devise-gem-for-api-token-authentication/</feedburner:origLink></item>
	</channel>
</rss>

