<?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://blog.coderubik.com</link>
	<description>Thoughts on Ruby on Rails and Facebook development</description>
	<lastBuildDate>Thu, 07 Apr 2011 21:49:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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>Make Paypal PDF invoices with Payday</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/y1oj1jorPzA/</link>
		<comments>http://blog.coderubik.com/2011/04/make-paypal-pdf-invoices-with-payday/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 21:49:38 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.coderubik.com/?p=197</guid>
		<description><![CDATA[A lot of small web applications use Paypal as their primary gateway for accepting payments. Paypal takes care of the payment transactions for your application and sends the customer back to your site once the payment done. The only thing Paypal doesn&#8217;t do is proper invoicing. It sends confirmation emails with the transaction details but many [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of small web applications use <a href="http://paypal.com">Paypal</a> as their primary gateway for accepting payments. Paypal takes care of the payment transactions for your application and sends the customer back to your site once the payment done. The only thing Paypal doesn&#8217;t do is proper invoicing. It sends confirmation emails with the transaction details but many corporate customers require a well-formatted PDF invoice as a proof or purchase.</p>
<p><a href="https://github.com/commondream/payday">Payday</a> is a Ruby gem that will help you create simple invoices. It&#8217;s a generic PDF invoicing library and as I will show you in this tutorial, it can be easily used to help you create invoices from Paypal transactions.</p>
<p>First thing to do, add the gem to your Gemfile :</p>
<pre class="brush: ruby; title: ; notranslate">gem &quot;payday&quot;</pre>
<p>Next, you can create a rails initializer file with your company infos :</p>
<pre class="brush: ruby; title: ; notranslate">
# /config/initializers/payday.rb
Payday::Config.default.invoice_logo = &quot;#{Rails.root}/public/images/logo.png&quot;
Payday::Config.default.company_name = &quot;My Company inc.&quot;
Payday::Config.default.company_details = &quot;100 Sunset Blvd\nHollywood\nUnited States\ninfo@mycompany.com&quot;
</pre>
<p>When a client makes a purchase on Paypal, you can configure your account to receive Instant Payment Notifications (IPN). I save each transaction in a Payment model and dump the paypal IPN request params in a serialized hash called paypal_params. This is the method from my model class I use to generate the invoice :</p>
<pre class="brush: ruby; title: ; notranslate">
# app/models/payment.rb
serialize :paypal_params

def generate_pdf_invoice
  invoice = Payday::Invoice.new(
    :invoice_number =&gt; paypal_params['invoice'],
    :currency =&gt; paypal_params['mc_currency'])
  invoice.paid_at = invoice.due_at = created_at.to_date
  invoice.bill_to = invoice.ship_to = paypal_params.slice(
    'address_name', 'address_street', 'address_city',
    'address_zip', 'address_country').values.join(&quot;\n&quot;)
  invoice.line_items &lt;&lt; Payday::LineItem.new(
    :price =&gt; paypal_params['mc_gross'],
    :quantity =&gt; 1,
    :description =&gt; paypal_params['item_name'])
  invoice.notes = &quot;Thank you for your purchase!&quot;
  invoice.render_pdf
end
</pre>
<p>Obviously, you will want to adjust this code to fit what you are selling. In my case, there is always only one line item in my transactions.</p>
<p>Finally, I make the invoice downloadable from the user account page. The controller method works like this :</p>
<pre class="brush: ruby; title: ; notranslate">
# app/controllers/payments_controller.rb
def pdf_invoice
  payment = Payment.find_by_tx_id! params[:id]
  respond_to do |format|
    format.pdf do
      send_data payment.generate_pdf_invoice,
        :filename =&gt; payment.invoice_filename,
        :type =&gt; &quot;application/pdf&quot;  , :disposition =&gt; &quot;inline&quot;
    end
  end
end
</pre>
<p>Again, you will probably have to adjust this method for your own needs. Don&#8217;t forget to add the pdf mime type to the mime_types.rb initializer :</p>
<pre class="brush: ruby; title: ; notranslate">
# /config/initializers/mime_types.rb
Mime::Type.register 'application/pdf', :pdf
</pre>
<p>There&#8217;s a lot more you can do with Payday. It supports I18n and it integrates well with ActiveRecord. I encourage you to take a look at the <a href="https://github.com/commondream/payday">readme on github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coderubik.com/2011/04/make-paypal-pdf-invoices-with-payday/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.coderubik.com/2011/04/make-paypal-pdf-invoices-with-payday/</feedburner:origLink></item>
		<item>
		<title>Cookies and Facebook canvas apps</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/TjSnd-g5xpQ/</link>
		<comments>http://blog.coderubik.com/2011/03/cookies-and-facebook-canvas-apps/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 22:38:26 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.coderubik.com/?p=187</guid>
		<description><![CDATA[With the new Facebook way of loading iframes apps with POST requests, the safari third-party cookie problem is now partly fixed. It has always been a big headache dealing with cookies on the Facebook platform since Safari rejects them by default. With POST requests however, it is now possible to set cookies from the server. [...]]]></description>
			<content:encoded><![CDATA[<p>With the new Facebook way of loading iframes apps with <a href="http://developers.facebook.com/docs/canvas/post/">POST requests</a>, the safari third-party cookie problem is now partly fixed. It has always been a big headache dealing with cookies on the Facebook platform since Safari rejects them by default. With POST requests however, it is now possible to set cookies from the server. It seems Safari will still reject cookies set from the client.</p>
<p>So if you are using the Facebook Javascript SDK and set the cookies option to true, Safari won&#8217;t accept the FBS_XXXX cookie planted by the SDK. I struggled a whole week-end before <a href="http://forum.developers.facebook.net/viewtopic.php?pid=321880">figuring it out</a>.</p>
<p>The work-around I use is to set a cookie from the server with the signed_request in it if there is one present. This solves most of the problems since I can just use the cookie when I don&#8217;t have a fresh signed_request (this happens when I do a request inside the canvas).</p>
<p>Here is the code inside a before_filter in the application_controller. I use Rails with the <a href="https://github.com/mmangino/facebooker2">Facebooker2</a> gem :</p>
<p><script src="https://gist.github.com/861227.js?file=facebook_cookie.rb"></script></p>
<p>The P3P header is used to make IE6 and IE7 accept the cookie as well.</p>
<p>If you&#8217;re building a Facebook canvas application with Rails, take the time to also read <a title="Restful Facebook canvas app with Rails and POST For Canvas" href="http://blog.coderubik.com/2011/03/restful-facebook-canvas-app-with-rails-and-post-for-canvas/">my post about keeping your REST architecture with the POST requests</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coderubik.com/2011/03/cookies-and-facebook-canvas-apps/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://blog.coderubik.com/2011/03/cookies-and-facebook-canvas-apps/</feedburner:origLink></item>
		<item>
		<title>Restful Facebook canvas app with Rails and POST For Canvas</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/ZOjVrrwv4YA/</link>
		<comments>http://blog.coderubik.com/2011/03/restful-facebook-canvas-app-with-rails-and-post-for-canvas/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 18:49:16 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Facebook]]></category>

		<guid isPermaLink="false">http://blog.coderubik.com/?p=178</guid>
		<description><![CDATA[Update: The rack middleware is now included in Facebooker2. If you&#8217;re using Facebooker2, see the readme for details. Starting March 10th, The POST for canvas option will become mandatory for all Facebook canvas apps. This means all requests to your iframe originating from the Facebook frame will be POST requests. If you use restful controllers [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Update: The rack middleware is now included in <a href="https://github.com/mmangino/facebooker2">Facebooker2</a>. If you&#8217;re using Facebooker2, see the readme for details.</strong></em></p>
<p>Starting March 10th, The <a href="http://developers.facebook.com/docs/canvas/post/">POST for canvas</a> option will become mandatory for all Facebook canvas apps. This means all requests to your iframe originating from the Facebook frame will be POST requests. If you use restful controllers in your app, this is not a good news. Fortunately, there is a very easy way to convert those POST back to GET with a Rack middleware :</p>
<p><script src="https://gist.github.com/858939.js?file=facebook.rb"></script></p>
<p>Since all request coming from Facebook will include a <code>signed_request</code> parameter, you can assume that these requests are coming from the top frame. Other requests made directly from your iframe won&#8217;t be altered. You can safely now safely use  Post for canvas and continue to assume all requests coming from the top frame will be get requests.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coderubik.com/2011/03/restful-facebook-canvas-app-with-rails-and-post-for-canvas/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://blog.coderubik.com/2011/03/restful-facebook-canvas-app-with-rails-and-post-for-canvas/</feedburner:origLink></item>
		<item>
		<title>Create a Facebook poll</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/qDa5GT0CJLw/</link>
		<comments>http://blog.coderubik.com/2010/11/create-a-facebook-poll/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 23:49:08 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Facebook]]></category>

		<guid isPermaLink="false">http://blog.coderubik.com/?p=169</guid>
		<description><![CDATA[I recently launched an application that lets you create your polls on Facebook and publish them on your fan page. This was something I wanted to do for a while since I thought there were no good polling apps on Facebook. With Poll for Facebook, you can add as many questions as you want to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://apps.facebook.com/my-polls/welcome"><img class="alignleft" style="margin-top: 0px; margin-right: 10px; margin-bottom: 10px; margin-left: 0px;" title="Create your poll on Facebook" src="http://blog.coderubik.com/wp-content/uploads/2010/11/logo_180px.png" alt="" width="180" height="168" /></a>I recently launched an application that lets you create your polls on Facebook and publish them on your fan page. This was something I wanted to do for a while since I thought there were no good polling apps on Facebook.</p>
<p>With Poll for Facebook, you can add as many questions as you want to your poll, images and invite your friends to answer it. There is a free and a Premium version.</p>
<p>I encourage you to <a href="http://apps.facebook.com/my-polls/welcome">try it</a> and give me your feedback. It is now available in English, French, Spanish and German.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coderubik.com/2010/11/create-a-facebook-poll/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://blog.coderubik.com/2010/11/create-a-facebook-poll/</feedburner:origLink></item>
		<item>
		<title>Display a Google Map with Rails</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/ke7USjYl7xU/</link>
		<comments>http://blog.coderubik.com/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’ll see how to do this in three easy steps. [...]]]></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’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("gmap") 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 “gmap” (or whatever name you set in the <code>GMap.new</code> function). I find it’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’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://blog.coderubik.com/2009/10/display-a-google-map-in-rails/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://blog.coderubik.com/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/io9AzURheIA/</link>
		<comments>http://blog.coderubik.com/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’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 [...]]]></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’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’t get it working so I would advise to use the plugin :</p>
<pre>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>create_table "geolocations", :force =&gt; true do |t|
  t.string   "address"
  t.string   "city"
  t.float    "latitude"
  t.float    "longitude"
end</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’s my code in the <code>Geolocation.rb</code> model :</p>
<pre>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</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’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://blog.coderubik.com/2009/10/rails-geopositioning-with-google-maps/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://blog.coderubik.com/2009/10/rails-geopositioning-with-google-maps/</feedburner:origLink></item>
		<item>
		<title>Speeding up Tunnlr</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/5g4QEJIQaJE/</link>
		<comments>http://blog.coderubik.com/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[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. Typically, when working locally, your mongrel or webrick instance running on port 3000 is not accessible unless you [...]]]></description>
			<content:encoded><![CDATA[<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’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…), this solution won’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’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="brush: plain; title: ; notranslate">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="brush: plain; title: ; notranslate">
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><br />
[/code]script/server -p 10524[/code]</p>
<p>That’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://blog.coderubik.com/2009/09/speeding-up-tunnlr/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.coderubik.com/2009/09/speeding-up-tunnlr/</feedburner:origLink></item>
		<item>
		<title>redirect_to :back</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/xHFtR4WE49o/</link>
		<comments>http://blog.coderubik.com/2008/11/rails-redirect_to-back/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 19:07:00 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=10</guid>
		<description><![CDATA[Here&#8217;s a useful trick I didn&#8217;t know about! The command redirect_to :back does just what it says, it redirects the user back to the previous action. This is similar to redirect_to(request.env["HTTP_REFERER"]). The Rails documentation states that this can be useful for forms that are triggered from multiple places. In my case I needed it to [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a useful trick I didn&#8217;t know about! The command <code>redirect_to :back</code> does just what it says, it redirects the user back to the previous action. This is similar to <code>redirect_to(request.env["HTTP_REFERER"])</code>.</p>
<p><a href="http://api.rubyonrails.org/classes/ActionController/Base.html#M000478">The Rails documentation</a> states that this can be useful for forms that are triggered from multiple places.</p>
<p>In my case I needed it to redisplay the same page after a post that didn&#8217;t validate. I could redirect the user back to the right action but some request parameters were missing in the post action that prevented this to work right.</p>
<p>For example, if the last request was <code>/my_action?location=there</code>, I would lose the <code>location</code> parameter if I didn&#8217;t send it along in the post. And I didn&#8217;t want to send the parameter along since I was calling a different controller which business logic didn&#8217;t relate to these parameters.</p>
<p>Well, by using the HTTP referer, Rails redirects back to the URL with the right parameters and sends the user to the exact same location he was. Neat!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coderubik.com/2008/11/rails-redirect_to-back/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.coderubik.com/2008/11/rails-redirect_to-back/</feedburner:origLink></item>
		<item>
		<title>Alternate background colors with jQuery</title>
		<link>http://feedproxy.google.com/~r/ThoughtsOnTechnologyAndWebDevelopment/~3/3qKBkVGJEKA/</link>
		<comments>http://blog.coderubik.com/2008/09/alternate-background-colors-with-jquery/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 04:09:00 +0000</pubDate>
		<dc:creator>Pierre Olivier Martel</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://modelix.net/?p=7</guid>
		<description><![CDATA[I did a little javascript function with jQuery this morning to alternate DOM elements background colors. The function takes in parameters an array of jQuery elements and an array of hexadecimal colors and changes the background color of each element with the next color in the array. It&#8217;s only a three lines function but the [...]]]></description>
			<content:encoded><![CDATA[<p>I did a little javascript function with jQuery this morning to alternate DOM elements background colors. The function takes in parameters an array of jQuery elements and an array of hexadecimal colors and changes the background color of each element with the next color in the array.</p>
<pre class="brush: jscript; title: ; notranslate">
// Alternates the background colors of the elements
// elems  - Array of jQuery DOM objects
// colors - Array of hexadecimal colors
function alternateBgColor(elems, colors) {
    elems.each( function(index) {
    var colorIndex = index % colors.length;
    $(this).css('background-color', colors[colorIndex]);
  });
}
</pre>
<p>It&#8217;s only a three lines function but the cool thing about it is that you can alternate through as many colors as you need. I&#8217;m only using two for now but this could come useful at some point! I like how everything javascript just got easier with jQuery.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coderubik.com/2008/09/alternate-background-colors-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.coderubik.com/2008/09/alternate-background-colors-with-jquery/</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! -->

