<?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>redirect_to :hack</title>
	
	<link>http://modelix.net</link>
	<description>Thoughts on Ruby on Rails and Web development</description>
	<lastBuildDate>Mon, 22 Feb 2010 23:41:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ThoughtsOnTechnologyAndWebDevelopment" /><feedburner:info uri="thoughtsontechnologyandwebdevelopment" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Facebooker configs in database</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/RLEEXMP6tQA/</link>
		<comments>http://modelix.net/2010/02/facebooker-configs-in-database/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 23:29:34 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://modelix.net/2010/02/facebooker-config-in-database/</guid>
		<description><![CDATA[On a a recent project, I wanted to be able to fetch Facebooker configs from the database instead of the static facebooker.yml config file. This allows for greater flexibility, especially when you need to serve multiple Facebook applications from the same codebase.

In my case, I worked on a donation system on Facebook which is kind [...]]]></description>
			<content:encoded><![CDATA[<p>On a a recent project, I wanted to be able to fetch Facebooker configs from the database instead of the static <code>facebooker.yml</code> config file. This allows for greater flexibility, especially when you need to serve multiple Facebook applications from the same codebase.</p>

<p>In my case, I worked on a donation system on Facebook which is kind of like the <a href="http://www.facebook.com/apps/application.php?id=2318966938">Causes Facebook app</a> except that each cause gets its own Facebook app. The Facebook apps are created on the fly from the web admin interface by cause administrators and all the apps point to the same server.</p>

<p>The problem is that Facebooker does not allow serving multiple Facebook applications dynamically. I had to <a href="http://en.wikipedia.org/wiki/Monkey_patch">monkey patch</a> it in order to make it work. In my <code>config/initializers</code> folder, I created a new file named <code>facebooker.rb</code> with the following code :</p>



<pre class="prettyprint rb"><code>require 'facebooker'

module Facebooker
  class &lt;&lt; self  
    def fetch_config_for(api_key)
      cause = Cause.find_by_api_key(api_key)
      if cause
        cause.attributes.merge(&quot;callback_url&quot; =&gt; Settings.facebook.callback_url)
      else
        false
      end
    end
  end
end
</code></pre>



<p>The <code>fetch_config_for</code> method is called on each request to bind the request to a facebook application configuration. The original method looks for the config in <code>facebooker.yml</code>. This methods overrides that to use a database lookup instead. In the <code>Cause</code> model, I have fields named <code>canvas_page_name</code>, <code>api_key</code> and <code>secret_key</code>. The <code>callback_url</code> is the same for all the apps but it will change depending on the environment. I use the <a href="http://github.com/binarylogic/settingslogic">settingslogic</a> plugin to handle that.</p>

<p>Don&#8217;t forget to leave a dummy <code>facebooker.yml</code> file in the config folder since it&#8217;s loaded when the Facebooker plugins initializes.</p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2010/02/facebooker-configs-in-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://modelix.net/2010/02/facebooker-configs-in-database/</feedburner:origLink></item>
		<item>
		<title>Collaborative Facebook development with Facebooker</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/jDsC8VG9SVg/</link>
		<comments>http://modelix.net/2010/02/collaborative-facebook-development-with-facebooker/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 16:33:30 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=147</guid>
		<description><![CDATA[I&#8217;m currently consulting at Webdweller, a social advertisement platform that integrates with many social networks including Facebook. We are three developers on the team and we all need to collaborate building a Facebook application. Here&#8217;s a quick overview of how we did our setup.

1- Setup a local_env.rb file

Create a local_env.rb file in which you will [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently consulting at <a href="http://webdweller.com">Webdweller</a>, a social advertisement platform that integrates with many social networks including Facebook. We are three developers on the team and we all need to collaborate building a Facebook application. Here&#8217;s a quick overview of how we did our setup.</p>

<h2>1- Setup a <code>local_env.rb</code> file</h2>

<p>Create a <code>local_env.rb</code> file in which you will put all your environment variables. This works great with <a href="http://heroku.com">Heroku</a>. This technique is better explained in the article <a href="http://tammersaleh.com/posts/managing-heroku-environment-variables-for-local-development">Managing Heroku environment variables for local development</a>. The <code>local_env.rb</code> file is not checked in your version control. It remains on your local development machine and it&#8217;s loaded by your <code>environment.rb</code> file. I declare my <a href="http://tunnlr.com">Tunnlr</a> and Facebook configuration keys this way :</p>



<pre class="prettyprint rb"><code># config/local_env.rb
ENV['FACEBOOK_API_KEY']            = '1cv10ddbd7c4374e70996071343c9ed5'
ENV['FACEBOOK_SECRET_KEY']         = '39c4c4c060a5fd8335a21e22bdb2w26c6'
ENV['FACEBOOK_CALLBACK_URL']       = 'http://web1.tunnlr.com:10521'
ENV['FACEBOOK_CANVAS_PAGE_NAME']   = 'my-facebook-app'

ENV['TUNNLR_PUBLIC_HOST_USERNAME'] = 'tunnlr917'
ENV['TUNNLR_PUBLIC_HOST']          = 'ssh1.tunnlr.com'
ENV['TUNNLR_PUBLIC_PORT']          = '10521'
ENV['TUNNLR_LOCAL_PORT']           = '3000'

# config/environment.rb
# Load heroku vars from local file
# credits: http://tammersaleh.com/posts/managing-heroku-environment-variables-for-local-development
local_env = File.join(RAILS_ROOT, 'config', 'local_env.rb')
load(local_env) if File.exists?(local_env)
</code></pre>



<p>Replace those values with your Facebook application keys and tunnlr keys. Each developer is going to need it&#8217;s own <a href="http://facebook.com/developers">Facebook App</a> and it&#8217;s own <a href="http://tunnlr.com">Tunnlr</a> account.</p>

<h2>2- Put the variables in <code>facebooker.yml</code></h2>

<p><code>Facebooker.yml</code> is where &#8220;facebooker&#8221;: fetch its configurations. Reading the Facebooker source code, I realized the file is first parsed in <span class="caps">ERB, </span>which lets you put variables in your <span class="caps">YAML </span>file. We can put the variables we declared in step 1 :</p>



<pre class="prettyprint rb"><code>development: &amp;development
  api_key: &lt;%= ENV['FACEBOOK_API_KEY'] %&gt;
  secret_key: &lt;%= ENV['FACEBOOK_SECRET_KEY'] %&gt;
  callback_url: &lt;%= ENV['FACEBOOK_CALLBACK_URL'] %&gt;
  canvas_page_name: &lt;%= ENV['FACEBOOK_CANVAS_PAGE_NAME'] %&gt;
  pretty_errors: true
  tunnel:
    public_host_username: &lt;%= ENV['TUNNLR_PUBLIC_HOST_USERNAME'] %&gt;
    public_host: &lt;%= ENV['TUNNLR_PUBLIC_HOST'] %&gt;
    public_port: &lt;%= ENV['TUNNLR_PUBLIC_PORT'] %&gt;
    local_port: &lt;%= ENV['TUNNLR_LOCAL_PORT'] %&gt;

test:
  &lt;&lt;: *development
</code></pre>



<h2>3- That&#8217;s it!</h2>

<p>Each developer now has its own configuration for Facebook and Tunnlr and the keys are stored in <code>local_env.rb</code>. This file is not checked in git. This way, all the developers can then share the same facebooker.yml file.</p>

<p>See my other article on <a href="http://modelix.net/2009/09/speeding-up-tunnlr/">speeding up Tunnlr</a> for more tips on developping Facebook applications.</p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2010/02/collaborative-facebook-development-with-facebooker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://modelix.net/2010/02/collaborative-facebook-development-with-facebooker/</feedburner:origLink></item>
		<item>
		<title>Display a Google Map with Rails</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/D7MdafvY3jY/</link>
		<comments>http://modelix.net/2009/10/display-a-google-map-in-rails/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 13:07:28 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=137</guid>
		<description><![CDATA[In my last article on geopositioning with Rails and Google maps, we saw how to use the YM4R/GM plugin to find and store the longitude/latitude of an address using the Google Maps api. With these informations, we can now display the map to the user. We&#8217;ll see how to do this in three easy steps.

1. [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="/2009/10/rails-geopositioning-with-google-maps/">my last article on geopositioning with Rails and Google maps</a>, we saw how to use the <a href="http://ym4r.rubyforge.org/"><span class="caps">YM4R</span>/GM plugin</a> to find and store the longitude/latitude of an address using the Google Maps api. With these informations, we can now display the map to the user. We&#8217;ll see how to do this in three easy steps.</p>

<h2>1. Prepare the map in your model</h2>

<p>In your <code>Geolocation</code> model, start by adding this snippet of code which will initialize your map.</p>



<pre class="prettyprint rb"><code>def map
  @map ||= prepare_map
end

def mapped?
  latitude &amp;&amp; longitude
end

def coordinates
  [latitude, longitude]
end

private

def prepare_map
  return unless mapped?
  returning GMap.new(&quot;gmap&quot;) do |map| 
    map.control_init(:large_map =&gt; true, :map_type =&gt; true)
    map.center_zoom_init(coordinates, 15) # Set the center and zoo level
    map.overlay_init(GMarker.new(coordinates))
  end
end
</code></pre>



<p>The important method here is <code>prepare_map</code>. What it does is create a new map centered at the given coordinates. The <code>overlay_init</code> method sets a marker at the coordinates position. This is a basic vanilla map initialization. You might want to read the <a href="http://ym4r.rubyforge.org/ym4r_gm-doc/"><span class="caps">YM4R </span>api</a> for more options like adding an info window or multiple markers.</p>

<h2>2. Call it from your controller</h2>

<p>In our controller, we will set the <code>@map</code> variable to make it accessible in our view :</p>



<pre class="prettyprint rb"><code>@map = customer.geolocation.map</code></pre>



<h2>3. Display the map in your view</h2>

<p>You will need this snippet of code in the <code>header</code> section of your document to do the proper javascript imports and initializations :</p>



<pre class="prettyprint rb"><code>= GMap.header
= @map.to_html
</code></pre>



<p>And in the body of your view, where you want to display the map, simply add :</p>



<pre class="prettyprint rb"><code>@map.div(:width =&gt; 600, :height =&gt; 400)</code></pre>



<p>This last line will generate a div with the id &#8220;gmap&#8221; (or whatever name you set in the <code>GMap.new</code> function). I find it&#8217;s cleaner to just set the width an height through <span class="caps">CSS.</span></p>

<h2>4. Adding complexity</h2>

<p>This technique will only work if you display only one map on the page. The map needs to be visible on page load to be properly displayed. But what if there is multiple maps you want to display on the same page? And what if you want to show them in overlay popups? You probably don&#8217;t want to initialize them all on page load since it will freeze the client browser. This will require some javscript hacking. I will show you how to do that next week!</p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2009/10/display-a-google-map-in-rails/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://modelix.net/2009/10/display-a-google-map-in-rails/</feedburner:origLink></item>
		<item>
		<title>Rails geopositioning with Google Maps</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/VWnX0zcGwPo/</link>
		<comments>http://modelix.net/2009/10/rails-geopositioning-with-google-maps/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 14:57:37 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=128</guid>
		<description><![CDATA[A common problem when building a Rails web application that deals with addresses is geopositioning. Geopositioning can have different meaning depending on what you&#8217;re trying to achieve. In this article and the following, I will describe my solution to the following problems :



The user enters an address and you need to validate it and geoposition [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem when building a Rails web application that deals with addresses is geopositioning. Geopositioning can have different meaning depending on what you&#8217;re trying to achieve. In this article and the following, I will describe my solution to the following problems :</p>


<ol>
<li>The user enters an address and you need to validate it and <strong>geoposition it (latitude &amp; longitude)</strong> on a map.</li>
<li>You need to <strong>display the google map</strong> for that given address on a webpage.</li>
</ol>



<p>Today, I will show you how I did the first step using the <a href="http://ym4r.rubyforge.org/"><span class="caps">YM4R</span>/GM plugin</a>.</p>

<h2>1- Setup the plugin and get you Google Maps key</h2>

<p>First thing to do is to install the <a href="http://ym4r.rubyforge.org/"><span class="caps">YM4R</span>/GM plugin</a> plugin. There is also a gem but it seems to be a stripped-down version of the plugin. I couldn&#8217;t get it working so I would advise to use the plugin :</p>



<pre class="prettyprint rb">script/plugin install svn://rubyforge.org/var/svn/ym4r/Plugins/GM/trunk/ym4r_gm</pre>



<p>The plugin creates a file in your config folder named <code>gmaps_api_key.xml</code>. You need to enter your Google Maps <span class="caps">API </span>keys for the different environments. You can <a href="http://code.google.com/apis/maps/signup.html">get the keys here</a>.</p>

<h2>2- Create the model</h2>

<p>Next thing to do is to create your <code>Geolocation</code> activerecord model. You need to at least have those four attributes :</p>



<pre class="prettyprint rb"><code>create_table &quot;geolocations&quot;, :force =&gt; true do |t|
  t.string   &quot;address&quot;
  t.string   &quot;city&quot;
  t.float    &quot;latitude&quot;
  t.float    &quot;longitude&quot;
end
</code></pre>



<p>You might also want to add the country and postal code to the mix. But in most case, Google Maps will be able to return you a location with just a street address and a city.</p>

<h2>3- Set the geolocation on the before_save</h2>

<p>When you create a new gelocation record, you want to geoposition it. Here&#8217;s my code in the <code>Geolocation.rb</code> model :</p>



<pre class="prettyprint rb"><code>before_save :set_geolocation

def set_geolocation
  if changes['address'] || changes['city'] || !mapped?
    results = Geocoding::get(complete_address)
    if results.status == Geocoding::GEO_SUCCESS
      self.latitude, self.longitude = results[0].latlon
    else  
      self.latitude, self.longitude = nil
    end
  end
end

def complete_address
  [address, city].select(&amp;:present?).join(', ')
end

def mapped?
  latitude &amp;&amp; longitude
end
</code></pre>



<p>What this does is set the latitude and longitude for the given address on the before_save callback. We first check if the address or the city changed and if so we try to get a geocoding. If the <span class="caps">API </span>responds with <span class="caps">SUCCESS, </span>we set the latitude and longitude with the first result. If the <span class="caps">API </span>failed to return a valid address, we set the latitude and longitude to <code>nil</code>. We can check if the address was mapped using the <code>mapped?</code> method.</p>

<h2>4- Wrap it up</h2>

<p>Geopositionning  the address is only the first part of the problem. Next week I&#8217;ll show you how to use the latitude and longitude information we stored to display Google maps in your webpages.</p>

<p><a href="/2009/10/display-a-google-map-in-rails/"><strong>Next week : How to display a google map for a geopositioned address</strong></a></p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2009/10/rails-geopositioning-with-google-maps/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://modelix.net/2009/10/rails-geopositioning-with-google-maps/</feedburner:origLink></item>
		<item>
		<title>Generate RSS feeds on the fly with Feed43</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/N9JHHsl5vDI/</link>
		<comments>http://modelix.net/2009/09/generate-rss-feeds-on-the-fly-with-feed43/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 19:12:34 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=115</guid>
		<description><![CDATA[ Working as a freelancer, I have to monitor job boards, twitter keywords and other news channels so that I&#8217;m the first to know when someone needs a Rails developer for a contract project in Montreal or elsewhere. I manage all this information through RSS feeds with the help of Google Reader.

On some rare occasion, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://feed43.com"><img src="http://modelix.net/wp-content/uploads/2009/09/feed_43.png" alt="" height="57" width="186" class="left" style="float:left" /></a> Working as a freelancer, I have to monitor job boards, twitter keywords and other news channels so that I&#8217;m the first to know when someone needs a Rails developer for a contract project in Montreal or elsewhere. I manage all this information through <span class="caps">RSS </span>feeds with the help of <a href="http://www.google.com/reader/">Google Reader</a>.</p>

<p>On some rare occasion, I stumble on a job listing site that has no support for <span class="caps">RSS </span>feed. This is the case for the <a href="http://www.workingwithrails.com/browse/jobs/recent">Working With Rails job board</a>. Apparently I&#8217;m <a href="http://www.workingwithrails.com/forums/2-working-with-rails-website/topics/137-next-function-for-the-wwr-community">not the only one complaining</a> about the lack of a <span class="caps">RSS </span>feed for the job board.</p>

<p>I did some Google searches and found <a href="http://feed43.com">Feed43</a>, a nice little web app that lets you build a <span class="caps">RSS </span>feed for any pages on the web. It&#8217;s free, intuitive and fairly easy to build your own <span class="caps">RSS </span>feed if you&#8217;re a little tech savvy. If you&#8217;re also looking for Rails gigs, feel free to use <a href="http://feed43.com/wwr-jobs.xml">my generated <span class="caps">WWR </span>job board feed</a>!</p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2009/09/generate-rss-feeds-on-the-fly-with-feed43/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://modelix.net/2009/09/generate-rss-feeds-on-the-fly-with-feed43/</feedburner:origLink></item>
		<item>
		<title>Distinguish your environments with favicons</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/rwuSe6BntxU/</link>
		<comments>http://modelix.net/2009/09/distinguish-your-environments-with-favicons/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 12:10:22 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=96</guid>
		<description><![CDATA[I have to admit it, I&#8217;m a real neat freak when it comes to my desktop organization. The same goes with Firefox. I like to keep it clean and minimalistic. That&#8217;s why I&#8217;m using a few Firefox extensions and scripts to hide bookmarks and tab titles.

When I developed SalsaJungle.com, I was sometimes confusing my development [...]]]></description>
			<content:encoded><![CDATA[<p>I have to admit it, I&#8217;m a real neat freak when it comes to my desktop organization. The same goes with Firefox. I like to keep it clean and minimalistic. That&#8217;s why I&#8217;m using a few <a href="https://addons.mozilla.org/en-US/firefox/addon/3780">Firefox</a> <a href="https://addons.mozilla.org/fr/firefox/addon/2108">extensions</a> and <a href="http://userstyles.org/styles/10169">scripts</a> to hide bookmarks and tab titles.</p>

<p>When I developed <a href="http://montreal.salsajungle.com">SalsaJungle.com</a>, I was sometimes confusing my development and production websites. I know it doesn&#8217;t sound too clever but there are times when I reloaded a page after a fix only to realize that I was looking at the production site. That&#8217;s what happen when you multitask between development and client support.</p>

<p><div class="imagecaptioneasy imagecaptioneasy_nowrap" style="width:539px;"><img src="http://modelix.net/wp-content/uploads/2009/09/screen_capture4.png" alt="Notice the last two tabs which are running the same application on two different environments" height="198" width="539" /><br style="clear:both" /><span>Notice the last two tabs which are running the same application on two different environments</span></div></p>

<p>Well I took the matter in hands and simply created a second favicon with a different background color for my development environment. I named it <code>favicon_dev.ico</code> and put it in the same directory as the <code>favicon.ico</code>. Then I added this little snippet of <a href="http://haml-lang.com/">haml</a> code to my <code>application.html.haml</code> template :</p>



<pre class="prettyprint rb"><code>- if RAILS_ENV == 'development'
  %link{ :rel =&gt; &quot;shortcut icon&quot;, :href =&gt; &quot;/favicon_dev.ico&quot; }
</code></pre>



<p>With this code, I force the path of the favicon to <code>favicon_dev.ico</code> in the development environment.</p>

<p>Et voila! Now I know at a glance that blue is for development and red for production!</p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2009/09/distinguish-your-environments-with-favicons/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://modelix.net/2009/09/distinguish-your-environments-with-favicons/</feedburner:origLink></item>
		<item>
		<title>5 tips for a viral Facebook Connect application</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/OpvKq6UTnm8/</link>
		<comments>http://modelix.net/2009/09/5-tips-for-a-viral-facebook-connect-application/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 14:25:42 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=72</guid>
		<description><![CDATA[This the fourth article of a series of 4 articles on Facebook Connect.

This fourth and last article about Facebook Connect gives you a few tricks to gain a viral effect with your application on Facebook. This is basically done by getting friends of your users to notice your application.

1- Post updates on your users walls

Using [...]]]></description>
			<content:encoded><![CDATA[<p><i>This the fourth article of a <a href="http://modelix.net/2009/09/5-questions-to-ask-yourself-before-developing-for-facebook-connect/">series of 4 articles</a> on Facebook Connect.</i></p>

<p>This fourth and last article about Facebook Connect gives you a few tricks to gain a viral effect with your application on Facebook. This is basically done by getting friends of your users to notice your application.</p>

<h2>1- Post updates on your users walls</h2>

<p>Using the <a href="http://wiki.developers.facebook.com/index.php/Stream.publish">Stream.publish</a> function, you can post news on your users walls that will appear on their friends newsfeeds. There are different ways to do this and it requires some extra permissions from you users if you wish to auto-publish without users approval each time. Personally, I prefer to let my users decide whether they want the application to publish on their feed and they can personalize the content of the message :</p>

<p><div class="imagecaptioneasy imagecaptioneasy_nowrap" style="width:600px;"><img src="http://modelix.net/wp-content/uploads/2009/09/screen_capture.png" alt="The dialog asking to publish on your wall" height="201" width="600" /><br style="clear:both" /><span>The dialog asking to publish on your wall</span></div></p>

<h2>2- Add the friends invitation widget</h2>

<p>The invitation widget lets your users invite friends to try your application. I used <a href="http://facebooker.pjkh.com/connect/invite-friends">this code</a> to get it done. Unfortunately, the restriction on how many friends you can invite per day is rather draconian.</p>

<p><div class="imagecaptioneasy imagecaptioneasy_nowrap" style="width:600px;"><img src="http://modelix.net/wp-content/uploads/2009/09/screen_capture2.png" alt="Friends invitation dialog" height="408" width="600" /><br style="clear:both" /><span>Friends invitation dialog</span></div></p>

<h2>3- Add the Fanbox widget</h2>

<p><a href="http://wiki.developers.facebook.com/index.php/Fan_Box">This widget</a> is a simple snippet of code that adds a Fanbox to your page. When a Facebook user become fan of you application, it&#8217;s displayed in his friends newsfeed highlights (column on the right).</p>

<p><div class="imagecaptioneasy imagecaptioneasy_nowrap" style="width:185px;"><img src="http://modelix.net/wp-content/uploads/2009/09/screen_capture3.png" alt="SalsaJungle.com Fanbox" height="75" width="185" /><br style="clear:both" /><span>SalsaJungle.com Fanbox</span></div></p>

<h2>4- Use Facebook comments system</h2>

<p>Another very interesting widget that you can configure in a minute is the <a href="http://wiki.developers.facebook.com/index.php/Comments_Box">comment box</a>. You get the basic comment thread (Facebook style) and the user can choose to publish his comment on his profile. And this equals more visibility for your app.</p>

<p><div class="imagecaptioneasy imagecaptioneasy_nowrap" style="width:553px;"><img src="http://modelix.net/wp-content/uploads/2009/09/screen_capture_1.png" alt="The Facebook comment box" height="181" width="553" /><br style="clear:both" /><span>The Facebook comment box</span></div></p>

<h2>5- Optimize the Facebook links to your site</h2>

<p>When a Facebook user posts a link to your site in a status update or in a message to a friend, you want it to get noticed. Facebook automatically checks for images on your website to display with the link. It also figures out a description by parsing the text on page.</p>

<p>But instead of relying on luck, you should control all of this by using the description meta-tag and the link tag in your <span class="caps">HTML </span>header. You tell exactly Facebook which image and description to use when a link is made to a page of your site :</p>



<pre class="prettyprint html"><code>&lt;meta name=&quot;description&quot; content=&quot;My application description&quot; /&gt;
&lt;link rel =&quot;image_src&quot; href=&quot;http://montreal.salsajungle.com/images/logo_for_fb.gif&quot;&gt;
</code></pre>



<p>Note that the <code>image_src</code> href has to be absolute in order to work.</p>

<p><img src="http://modelix.net/wp-content/uploads/2009/09/screen_capture_2.png" alt="" height="142" width="531" /></p>

<p>That&#8217;s it! Your site should now get all the attention it deserves. Let me know in the comments if you have other ways to promote your Facebook Connect website.</p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2009/09/5-tips-for-a-viral-facebook-connect-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://modelix.net/2009/09/5-tips-for-a-viral-facebook-connect-application/</feedburner:origLink></item>
		<item>
		<title>Facebook Connect : Working with offline user’s data access</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/349lXFdqUSA/</link>
		<comments>http://modelix.net/2009/09/facebook-connect-working-with-offline-users-data-access/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 21:20:11 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=59</guid>
		<description><![CDATA[This the third article of a series of 4 articles on Facebook Connect. It assumes you&#8217;re using Rails and the Facebooker gem.

In my Facebook Connnect salsa network application, I have a cron task that runs each night to create new Facebook events associated with clubs. So for example, if there is a salsa night every [...]]]></description>
			<content:encoded><![CDATA[<p><i>This the third article of a <a href="http://modelix.net/2009/09/5-questions-to-ask-yourself-before-developing-for-facebook-connect/">series of 4 articles</a> on Facebook Connect. It assumes you&#8217;re using Rails and the <a href="http://github.com/mmangino/facebooker/tree/master">Facebooker</a> gem.</i></p>

<p>In my Facebook Connnect <a href="http://montreal.salsajungle.com">salsa network application</a>, I have a cron task that runs each night to create new Facebook events associated with clubs. So for example, if there is a salsa night every Tuesday at Moe&#8217;s bar, the related Facebook event will be created 7 days in advance on behalf of the administrator of the bar. But in order to create the events on behalf of a Facebook user that doesn&#8217;t have an active session on the site, there is a few steps to follow.</p>

<h2>1- Request the <code>offline_access</code> extended permission</h2>

<p>Some of the Facebook <span class="caps">API </span>functionalities require you to get <a href="http://wiki.developers.facebook.com/index.php/Extended_permissions">permission</a> from the user first. In this case, we need the offline_permission to access user&#8217;s data.</p>



<pre class="prettyprint rb"><code>&lt;div id=&quot;grant-permissions&quot;&gt;
  &lt;fb:prompt-permission perms=&quot;offline_access&quot; next_fbjs=&quot;$('#grant-permissions').hide()&quot;&gt;
    Click here to grant offline access!
  &lt;/fb:prompt-permission&gt;
&lt;/div&gt;
</code></pre>



<p>The previous line can be inserted in your view. The <a href="http://wiki.developers.facebook.com/index.php/XFBML"><span class="caps">XFBL</span></a> code creates a link to a popup prompt asking the user for offline access permission. The <code>next_fbjs</code> attribute is a javascript callback function that executes once the user has granted or refused the permission. In this case, we just hide the div using a jQuery function.</p>

<h2>2- Store the user&#8217;s infinite session key</h2>

<p>If the user has granted the <code>offline_access</code> permission, each request will now contain an infinite session key. We need to store this information somewhere in the DB if it&#8217;s not already there. In this case, I added a session_key attribute to my User model.</p>



<pre class="prettyprint html"><code># This goes in your application_controller.rb
before_filter :set_fb_session_key
def set_fb_session_key
  if logged_in? &amp;&amp; facebook_session.infinite? &amp;&amp; !current_user.fb_session_key
    current_user.update_attribute(:fb_session_key, facebook_session.session_key)
  end
end
</code></pre>



<p>You will notice that the keys have this format <code>&lt;random hexadecimal key&gt;-&lt;facebook user_id&gt;</code></p>

<h2>3- Use the session key to access user&#8217;s data</h2>

<p>Finally, you will be able to access your user&#8217;s datas through the Facebooker <span class="caps">API </span>by initalizing the session with the user&#8217;s session key this way:</p>



<pre class="prettyprint rb"><code>facebook_session = Facebooker::Session.create
facebook_session.secure_with!(user.fb_session_key)
</code></pre>



<p>That&#8217;s it! You can now use the user&#8217;s data as you wish!</p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2009/09/facebook-connect-working-with-offline-users-data-access/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://modelix.net/2009/09/facebook-connect-working-with-offline-users-data-access/</feedburner:origLink></item>
		<item>
		<title>Speeding up Tunnlr</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/NNRcYkvfSFY/</link>
		<comments>http://modelix.net/2009/09/speeding-up-tunnlr/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 20:24:21 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=51</guid>
		<description><![CDATA[This the second article of a series of 4 articles on Facebook Connect. It assumes you&#8217;re using Rails and the Facebooker gem.

When developing a Facebook or Facebook Connect application,  there are times when Facebook servers will need to directly make requests to your application. This means your local web server has to be remotely [...]]]></description>
			<content:encoded><![CDATA[<p><i>This the second article of a <a href="http://modelix.net/2009/09/5-questions-to-ask-yourself-before-developing-for-facebook-connect/">series of 4 articles</a> on Facebook Connect. It assumes you&#8217;re using Rails and the <a href="http://github.com/mmangino/facebooker/tree/master">Facebooker</a> gem.</i></p>

<p>When developing a Facebook or Facebook Connect application,  there are times when Facebook servers will need to directly make requests to your application. This means your local web server has to be remotely accessible for incoming requests.</p>

<p>Typically, when working locally, your mongrel or webrick instance running on port 3000 is not accessible unless you enable port forwarding on your router. And even then, your <span class="caps">ISP </span>probably doesn&#8217;t assign you a fixed IP address which means you have to run a dynamic IP address service like <a href="http://www.dyndns.com">dyndns</a>. This quickly gets complicated and if you work behind a corporate network or develop from different locations (ex.: home, office, Starbucks&#8230;), this solution won&#8217;t even work.</p>

<p>Meet <a href="http://www.tunnlr.com">Tunnlr</a>, an easy to use service that makes your local Rails server accessible from the Internet by just typing a single rake command in your console. When you register to the service, you will be assigned a fixed <span class="caps">URL </span>address with a port number and this is the address you will use to configure your Facebook application and access it locally.</p>

<p>One downside to that approach is that since each request has to do a return trip to the Tunnlr servers, you loose the lightning speed loading time you&#8217;re used to when developing from your local machine (no network latency). I found a little hack that will bypass the need to do a return trip and it can be done in three easy steps</p>

<p><strong>1- Modify your <code>/etc/hosts</code> file and add the following line :</strong></p>



<pre class="prettyprint">127.0.0.1	web1.tunnlr.com</pre>



<p>This tells your machine to route all requests made to the <code>web1.tunnlr.com</code> address to your local machine. Unfortunately, there is no way to specify port redirections in the hosts file so we need step 2 and 3 to make sure our remote and local ports are the same.</p>

<p><strong>2- Modify your tunnlr.yml or facebooker.yml file to make your local port the same as your remote port. In my case, this is port 10524.</strong></p>



<pre class="prettyprint">remote_port: 10524
local_port: 10524</pre>



<p><strong>3- Start your Rails server with the same port that has been assigned to you by Tunnlr.</strong></p>



<pre class="prettyprint">script/server -p 10524</pre>



<p>That&#8217;s it! Now when you query <code>web1.tunnlr.com</code> your local requests will stay local and your server will still be remotely accessible from the tubes!</p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2009/09/speeding-up-tunnlr/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://modelix.net/2009/09/speeding-up-tunnlr/</feedburner:origLink></item>
		<item>
		<title>5 questions to ask yourself before developing for Facebook Connect</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/kWwh0CkxEdA/</link>
		<comments>http://modelix.net/2009/09/5-questions-to-ask-yourself-before-developing-for-facebook-connect/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 06:56:43 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=20</guid>
		<description><![CDATA[ I spent most of my summer developing a social web application for the salsa dancing community in Montreal. I realized this project in part for fun and in part to seek new business opportunities. The application relies heavily on Facebook Connect for authentication and events management. Now that the website is mostly done and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://montreal.salsajungle.com"><img src="http://modelix.net/wp-content/uploads/2009/09/salsajunglecom_montreals_social_network.gif" alt="" height="38" width="172" class="right" style="float:right" /></a> I spent most of my summer developing a <a href="http://montreal.salsajungle.com">social web application for the salsa dancing community in Montreal</a>. I realized this project in part for fun and in part to seek new business opportunities. The application relies heavily on <a href="http://developers.facebook.com/connect.php">Facebook Connect</a> for authentication and events management. Now that the website is mostly done and online, I want to share my experience developing with Facebook Connect.</p>

<p>Over the course of the week, I will write one post a day about the following technical topics :</p>


<ol>
<li>Today: 5 strategies when developing with Facebook Connect</li>
<li>Wednesday: <a href="http://modelix.net/2009/09/speeding-up-tunnlr/">Speeding up Tunnlr</a></li>
<li>Thursday: <a href="http://modelix.net/2009/09/facebook-connect-working-with-offline-users-data-access/">Working with offline user&#8217;s data access</a></li>
<li>Friday: <a href="http://modelix.net/2009/09/5-tips-for-a-viral-facebook-connect-application/">Viral Facebook Connect application tips</a></li>
</ol>



<p>Stay tuned if you&#8217;re planning on developing a Facebook application or are curious about this new platform. So let&#8217;s start with today&#8217;s topic,  5 questions to ask yourself before you kick off your project:</p>

<h2>1- What will my interactions with the Facebook platform be? Are there <span class="caps">API </span>limitations?</h2>

<p>If there was only one advice I could give you, it would be to <strong>read the <a href="http://wiki.developers.facebook.com/index.php/API">Facebook <span class="caps">API</span></a> first</strong>. Your application will be limited in terms of what data it can access and how the data can be used. Knowing those limitations and how to get around them is essential.</p>

<p>As an example, I took for granted that I would be able to rsvp to events on Facebook on behalf of users. Turns out that when I carefully read the events <span class="caps">API, </span>rsvps would only work on events your application created. Now that was a real bummer that I could have managed earlier if I had read the <span class="caps">API </span>more carefully.</p>

<h2>2- What will my authentication strategy be?</h2>

<p><img src="http://modelix.net/wp-content/uploads/2009/09/facebook_connect.gif" alt="" height="25" width="194" class="right" style="float:right" /> Facebook Connect provides a way to authenticate users on your website. But <strong>should you rely entirely on Connect or should you provide an hybrid registration process</strong> that lets the user choose whether they prefer to create a new account for your site or use their Facebook account?</p>

<p>My application relies heavily on Facebook Connect so I decided not to provide other means of logging on to the site. Turns out this was maybe not such a great idea since a lot of people still don&#8217;t know about Facebook Connect and are concerned with phishing scams when entering their Facebook credentials to log on to my site.</p>

<h2>3- Which wrapper should I use?</h2>

<p>The wrapper is the link between your programming language and the Facebook <span class="caps">REST </span>api. <strong>In the Rails world, <a href="http://github.com/mmangino/facebooker/tree/master">Facebooker</a> is the obvious choice.</strong> The gem is stable and great developers are working on adding new features and fixes each week. But still, the Facebook <span class="caps">API </span>changes quickly and you might find yourself wanting to use features that haven&#8217;t made their way to the gem yet.</p>

<p>In that case, I woud recommend forking the project on GitHub and using it as a git submodule plugin in your application. This way you can add the missing features yourself and ask for a pull request once its done and tested.</p>

<h2>4- Facebook application or Facebook Connect?</h2>

<p>While Facebook Connect is new on the scene, Facebook applications have been around for a few years now and Facebook user are used to them. But <strong>I somehow feel the golden age of Facebook applications is behind.</strong> Users got fed up with all the noise and newsfeed clogging from those applications and Facebook responded by moving them away in separate tabs. As a result, it has got a lot more difficult for an application to get noticed and go viral.</p>

<p>Facebook connect will give you a lot more freedom and independence, letting you use the Facebook platform without being trapped in it.</p>

<h2>5- How will it go viral?</h2>

<p>Viral marketing is still one of the best argument as to why you should not neglect Facebook in your marketing strategy. <strong>You need to make the best use of your users newsfeed</strong> so that your application gets noticed by a maximum of potential users.</p>

<p><img src="http://modelix.net/wp-content/uploads/2009/09/facebook_newsfeed.png" alt="" height="79" width="491" /></p>

<p>Making your application go viral will be Friday&#8217;s subject.</p>

<p>What do you think of these tips? Do they make sense to you? Do you have a few others?</p>]]></content:encoded>
			<wfw:commentRss>http://modelix.net/2009/09/5-questions-to-ask-yourself-before-developing-for-facebook-connect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://modelix.net/2009/09/5-questions-to-ask-yourself-before-developing-for-facebook-connect/</feedburner:origLink></item>
	</channel>
</rss><!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
