<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ahabman &#187; code</title>
	<atom:link href="http://ahabman.com/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://ahabman.com/blog</link>
	<description></description>
	<lastBuildDate>Sun, 27 Nov 2011 19:52:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Rhythm visualization</title>
		<link>http://ahabman.com/blog/2011/04/rhythm-visualization/</link>
		<comments>http://ahabman.com/blog/2011/04/rhythm-visualization/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 00:32:43 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=167</guid>
		<description><![CDATA[Launch the rhythm visualization demo Continuing from my first iteration on a visual metronome, this is an improvement to simplify things while providing greater control in the UI for: tempo, cycles (bars), beats, and emphasis highlighting (nth). My intention is for this to evolve toward a metric modulation visualization. I moved from the traditional European [...]]]></description>
			<content:encoded><![CDATA[<h2><a href="http://ahabman.com/blog/wp-content/uploads/metronome-2/cycle.html" target="blank">Launch the rhythm visualization demo</a></h2>
<p>Continuing from my <a href="http://www.ahabman.com/blog/2009/09/visual-metronome/">first iteration on a visual metronome</a>, this is an improvement to simplify things while providing greater control in the UI for: tempo, cycles (bars), beats, and emphasis highlighting (n<sup><span style="font-size: 10px;">th</span></sup>). My intention is for this to evolve toward a metric modulation visualization.</p>
<p>I moved from the traditional European music notation of left to right / top to bottom, and used a more abstract top to bottom / left to right orientation. Most often I work with more bars than beats, so this worked nicely for laptop screen dimensions. Also, I enjoy nudging the musician away from the usual way we visually experience music.</p>
<p>Thanks to <a href="http://www.brothercake.com/">James Edwards</a> <a href="http://blogs.sitepoint.com/creating-accurate-timers-in-javascript/">article on javascript timing</a>, and of course the <a href="http://jquery.org/team">jQuery team</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2011/04/rhythm-visualization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command finished notification with Ruby</title>
		<link>http://ahabman.com/blog/2010/09/command-finished-notification-with-ruby/</link>
		<comments>http://ahabman.com/blog/2010/09/command-finished-notification-with-ruby/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 23:02:07 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=125</guid>
		<description><![CDATA[I wanted a visual notification in Ubuntu when long running commands finished in Terminal. My solution, run the command and pipe it into notify. $ a-long-running-command &#124; notify notify.rb Make it executable add an alias to it in ~/.bashrc Requires: ruby, rubygems, and libnotify. Similar solutions: &#8220;alert&#8221; alias (I&#8217;ll be switching to this in Maverick), [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted a visual notification in Ubuntu when long running commands finished in Terminal. My solution, run the command and pipe it into notify.</p>
<p>$ a-long-running-command | notify</p>
<p><a href="http://www.ahabman.com/blog/wp-content/uploads/2010/09/notify.png"><img title="notify" src="http://www.ahabman.com/blog/wp-content/uploads/2010/09/notify-300x188.png" alt="" width="300" height="188" /></a></p>
<p>notify.rb</p>
<pre class="brush: ruby; title: ; notranslate">#!/usr/bin/env ruby
require 'rubygems'
require 'libnotify'
Libnotify.show :summary =&gt; &quot;Command finished.&quot;, :body =&gt; &quot;#{ARGF.read}&quot;</pre>
<p>Make it executable</p>
<pre class="brush: bash; title: ; notranslate">chmod u+x ~/scripts/notify.rb</pre>
<p>add an alias to it in ~/.bashrc</p>
<pre class="brush: bash; title: ; notranslate">alias notify=&quot;~/scripts/notify.rb&quot;</pre>
<p>Requires: <a href="http://www.ruby-lang.org/en/"><br />
ruby</a>, <a href="http://rubygems.org/">rubygems</a>, and <a href="http://github.com/vargolo/ruby-libnotify">libnotify</a>.</p>
<p>Similar solutions:<br />
<a href="http://blog.dustinkirkland.com/2010/07/dear-command-line-please-ping-me-when.html">&#8220;alert&#8221; alias</a> (I&#8217;ll be switching to this in Maverick), <a href="http://blogs.divisibleprime.com/ronin/articles/2008/03/10/command-line-gnome-notification"><br />
a python version</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2010/09/command-finished-notification-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Metronome</title>
		<link>http://ahabman.com/blog/2009/09/visual-metronome/</link>
		<comments>http://ahabman.com/blog/2009/09/visual-metronome/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 02:19:41 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=67</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://www.ahabman.com/blog/wp-content/uploads/metronome-js/metronome.html" width="650" height="850"  style="border:none;"></iframe></p>
<pre class="brush: jscript; title: ; notranslate">
/*
 * metronome
 */
int stage = 600;
int mains = int(random(3,9) );
int subs = int(random(3,6) );
float moon_size = 3;
int bpm = 60;
int active_main = 0;
int active_sub = 0;
color main_color = #292B89;
color first_color = #1A1B55;
color active_color = 0x95FFFFFF;
int my_frame_rate = 12;
float bps = float(bpm) / 60 ;

void setup() {
  size(stage, stage);
  frameRate(my_frame_rate);
  noStroke();
}
void draw() {
  background(#989898);
  if( frameCount % (my_frame_rate/bps) &amp;lt; 1 ){
    active_main+=1;
    if(active_main&amp;gt;=mains){
      active_main=0;
    }
  }
  if( frameCount % (my_frame_rate/bps/subs) &amp;lt; 1 ){
    active_sub+=1;
    if(active_sub==subs){
      active_sub=0;
    }
  }
  Circle a = new Circle(width/2, height/2, stage/2, mains);
  a.make_moons( active_main );
  a.moons[active_main].make_moons( active_sub );
}
void mouseMoved(){
  mains = 2 + mouseX /(stage/10);
  moon_size = mains/1.555;
  active_main=0;
}
class Circle{
  float r, x, y;
  int active_moon, each_angle, sections;
  Circle moons[] = new Circle[23];

  Circle(float x_init,float y_init,float r_init, int divisions_init){
    x = x_init;
    y = y_init;
    r = r_init;
    sections = divisions_init;
    each_angle = 360 / sections;
  }
  void make(){
    ellipse(x, y, r, r);
  }
  void make_moons( int active_moon ){
    int angle = each_angle;
    for(int i = 0; i &amp;lt; sections; i+=1 ){
      float moon_x = x + cos(radians(angle)) * (r/2);
      float moon_y = y + sin(radians(angle)) * (r/2);
      moons[i] = new Circle(moon_x, moon_y, r / 4, subs);
      if(i==active_moon){fill(active_color);}else if(i==0){fill(first_color);} else{fill(main_color);} // HIGHLIGHT FIRST &amp;amp; ACTIVE MOON
      moons[i].make();
      angle = angle + each_angle;
    }
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2009/09/visual-metronome/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ruby Duration</title>
		<link>http://ahabman.com/blog/2009/06/ruby-duration/</link>
		<comments>http://ahabman.com/blog/2009/06/ruby-duration/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 13:02:57 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=39</guid>
		<description><![CDATA[Download ruby duration lib Duration.new recieves a string describing a duration of time, and converts it into: seconds, and a standard readable format. Or, you can pass Duration.new an integer representing seconds, and receive the same standard readable format. Usage: Passing a String Passing an Fixnum (of seconds) &#160; Example valid input strings: &#8220;2 weeks&#8221;, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ahabman.com/blog/wp-content/uploads/2009/06/duration.zip">Download ruby duration lib</a></p>
<p>Duration.new recieves a string describing a duration of time, and converts it into: seconds, and a standard readable format.<br />
Or, you can pass Duration.new an integer representing seconds, and receive the same standard readable format.</p>
<p>Usage:</p>
<p>Passing a String</p>
<pre class="brush: ruby; title: ; notranslate">
duration = Duration.new(&quot;2weeks 8 hr 30m&quot;)
duration.seconds  # =&gt; 1240200
duration.readable  # =&gt; &quot;2 weeks, 8 hours and 30 mins&quot;
</pre>
<p>Passing an Fixnum (of seconds)</p>
<pre class="brush: ruby; title: ; notranslate">
duration = Duration.new(1240200)
duration.readable  # =&gt; &quot;2 weeks, 8 hours and 30 mins&quot;
</pre>
<p>&nbsp;</p>
<p>Example valid input strings:</p>
<p>&#8220;2 weeks&#8221;, &#8220;2wks&#8221;, &#8220;2w&#8221;,<br />
&#8220;8h&#8221;, &#8220;8 hrs&#8221;,&#8221;8 hours&#8221;,<br />
&#8220;30m&#8221;, &#8220;0:30&#8243;, &#8220;30 minutes&#8221;, &#8220;30min&#8221;,<br />
&#8220;2 weeks, 8 hours and 30 minutes&#8221;, &#8220;2w 8h 30m&#8221;, &#8220;2w 8:30&#8243;,<br />
&#8220;4 hours 30 minutes&#8221;, &#8220;4 hours and 30m&#8221;, &#8220;4h 30min&#8221;, &#8220;4:30&#8243;, &#8220;4.5&#8243;, &#8220;4.50&#8243;, &#8220;4h, 30 min&#8221;, &#8220;4.5 hours&#8221;, &#8220;4.50h&#8221;</p>
<p>&nbsp;</p>
<p><a href="http://ahabman.com">ahabman</a> added functionality, extended and mashed-up this <a href="http://stackoverflow.com/questions/657309/how-to-parse-days-hours-minutes-seconds-in-ruby">stack overflow article</a> and <a href="http://www.postal-code.com/binarycode/2007/04/04/english-friendly-timespan/">english friendly timespan</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2009/06/ruby-duration/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>rails template</title>
		<link>http://ahabman.com/blog/2009/03/rails-template/</link>
		<comments>http://ahabman.com/blog/2009/03/rails-template/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 04:14:08 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=37</guid>
		<description><![CDATA[Usage $ rails app_name -m ./ahabman_template.rb]]></description>
			<content:encoded><![CDATA[<p>Usage $ rails app_name -m ./ahabman_template.rb</p>
<pre class="brush: ruby; title: ; notranslate">

run &quot;rm README&quot;
run &quot;rm public/index.html&quot;
run &quot;rm public/favicon.ico&quot;
run &quot;rm public/robots.txt&quot;
run &quot;rm -f public/javascripts/*&quot;

gem 'ruby-openid', :lib =&gt; 'openid'
rake(&quot;gems:install&quot;, :sudo =&gt; true)

plugin &quot;kamui_restful_authentication&quot;, :git =&gt; 'git://github.com/kamui/restful-authentication.git'
plugin 'exception_notifier', :git =&gt; 'git://github.com/rails/exception_notification.git'
plugin 'open_id_authentication', :git =&gt; 'git://github.com/rails/open_id_authentication.git'
#plugin 'asset_packager', :git =&gt; 'http://synthesis.sbecker.net/pages/asset_packager'
plugin 'role_requirement', :git =&gt; 'git://github.com/timcharper/role_requirement.git'
#plugin 'acts_as_taggable_redux', :git =&gt; 'http://github.com/geemus/acts_as_taggable_redux/tree/master'
#plugin 'restful-authentication', :git =&gt; 'git://github.com/technoweenie/restful-authentication.git'

generate(&quot;authenticated user sessions --include-activation --include-forgot-password --email-as-login&quot;)
generate(&quot;roles&quot;, &quot;Role User&quot;)

#rake('acts_as_taggable:db:create')
rake(&quot;open_id_authentication:db:create&quot;)
rake('db:migrate')

route &quot;map.root :controller =&gt; 'sessions', :action =&gt; 'signup' &quot;

run &quot;echo generated from ahabman_template &gt; README&quot;
run &quot;cp config/database.yml config/example_database.yml&quot;

#if yes?(&quot;Do you want this thing?&quot;)
# ...
#end

#my_var = ask(&quot;was up&quot;)
#generate :something, my_var

puts &quot;SUCCESS!&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2009/03/rails-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby on rails &#8211; has and belongs to many view plugin</title>
		<link>http://ahabman.com/blog/2008/10/ruby-on-rails-has-and-belongs-to-many-view-plugin/</link>
		<comments>http://ahabman.com/blog/2008/10/ruby-on-rails-has-and-belongs-to-many-view-plugin/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 12:59:27 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=35</guid>
		<description><![CDATA[So I&#8217;ll never have to write another has_and_belongs_to_many view again, here&#8217;s a plugin that dynamically makes 2 &#60;ul&#62; lists which you drag and drop both ways to manage the association. http://svn.ahabman.com/public/many_to_many_view/ From the readme: Assumming you have an @project var and you want to associate people with it. "shared/m2m", :locals => { :thing => @project, [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ll never have to write another has_and_belongs_to_many view again, here&#8217;s a plugin that dynamically makes 2 &lt;ul&gt; lists which you drag and drop both ways to manage the association.</p>
<p><a href="http://svn.ahabman.com/public/many_to_many_view/">http://svn.ahabman.com/public/many_to_many_view/</a></p>
<p>From the readme:</p>
<p>Assumming you have an @project var and you want to associate people with it.</p>
<pre>
<div id="m2m_container">
<%= render :partial => "shared/m2m", :locals => {
:thing => @project,
:association => 'people',
:association_attr => 'first_name' } %>
</div>
</pre>
<p>:thing take the current object<br />
:association takes the pluralized association, a string.<br />
:association_attr takes the attribute of the associated object that will be displayed.</p>
<p><a href="http://www.ahabman.com/blog/wp-content/uploads/2008/10/many-to-many-view-plugin.png"><img class="alignnone size-medium wp-image-36" title="many-to-many-view-plugin" src="http://www.ahabman.com/blog/wp-content/uploads/2008/10/many-to-many-view-plugin.png" alt="" width="471" height="253" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2008/10/ruby-on-rails-has-and-belongs-to-many-view-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You can&#8217;t use class variables in rails.</title>
		<link>http://ahabman.com/blog/2008/10/you-cant-use-class-variables-in-rails/</link>
		<comments>http://ahabman.com/blog/2008/10/you-cant-use-class-variables-in-rails/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 12:51:12 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=34</guid>
		<description><![CDATA[You can&#8217;t use class variables in rails. Unless you&#8217;d like to develop in production mode (specifically with config.cache_classes = true). In development mode all classes are reloaded on each request, which clears all class variables. I had the perfect place to use them &#8211; while running a mass synchronization, and needing to store the timestamp [...]]]></description>
			<content:encoded><![CDATA[<p>You can&#8217;t use class variables in rails. Unless you&#8217;d like to develop in production mode (specifically with config.cache_classes = true).  In development mode all classes are reloaded on each request, which clears all class variables.</p>
<p>I had the perfect place to use them &#8211; while running a mass synchronization, and needing to store the timestamp (I couldn&#8217;t use the latest last_updated from each record).  It worked perfect in ./script/console but failed entirely through the browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2008/10/you-cant-use-class-variables-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby csv to structured hash</title>
		<link>http://ahabman.com/blog/2008/09/ruby-csv-to-structured-hash/</link>
		<comments>http://ahabman.com/blog/2008/09/ruby-csv-to-structured-hash/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 20:29:02 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=31</guid>
		<description><![CDATA[I had a csv like this: object color flavor shape apple red sweet round banana yellow sweet long lemon yellow sour round and I wanted a ruby hash structured like this: So I wrote this, which does the job:]]></description>
			<content:encoded><![CDATA[<p>I had a csv like this:</p>
<table style="height: 84px;" border="1" width="166">
<tbody>
<tr>
<th>object</th>
<th>color</th>
<th>flavor</th>
<th>shape</th>
</tr>
<tr>
<td>apple</td>
<td>red</td>
<td>sweet</td>
<td>round</td>
</tr>
<tr>
<td>banana</td>
<td>yellow</td>
<td>sweet</td>
<td>long</td>
</tr>
<tr>
<td>lemon</td>
<td>yellow</td>
<td>sour</td>
<td>round</td>
</tr>
</tbody>
</table>
<p>and I wanted a ruby hash structured like this:</p>
<pre class="brush: ruby; title: ; notranslate">
{
'apple'=&gt; { 'color'=&gt;'red', 'flavor'=&gt;'sweet', 'shape'=&gt;'round'},
'banana'=&gt; { 'color'=&gt;'yellow', 'flavor'=&gt;'sweet', 'shape'=&gt;'long'},
'lemon'=&gt; { 'color'=&gt;'yellow', 'flavor'=&gt;'sour', 'shape'=&gt;'round'}
}
</pre>
<p>So I wrote this, which does the job:</p>
<pre class="brush: ruby; title: ; notranslate">
require &quot;faster_csv&quot;

def csv_to_structured_hash
	arr_of_arrs = FasterCSV.read( 'your.csv' )
	stuff = {}
	header = arr_of_arrs.shift
		arr_of_arrs.each_with_index do |row, i|
		thing = { row[0] =&gt; {} }
			header.each_with_index do |col, header_index|
			thing[ row[0] ][ header[header_index] ] = row[ header_index]
			end
		stuff.update( thing )
		end
	return stuff
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2008/09/ruby-csv-to-structured-hash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby conversion module</title>
		<link>http://ahabman.com/blog/2008/07/ruby-conversion-module/</link>
		<comments>http://ahabman.com/blog/2008/07/ruby-conversion-module/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 12:52:11 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=26</guid>
		<description><![CDATA[This is a ruby module useful for conversions dealing with length, weight, torque.]]></description>
			<content:encoded><![CDATA[<p>This is a <a href="http://www.ahabman.com/blog/wp-content/uploads/2008/07/convert.rb">ruby module useful for conversions</a> dealing with length, weight, torque.</p>
<pre class="brush: ruby; title: ; notranslate">
 module Convert 

   def Convert.number_with_precision(number, precision=2)
     &quot;%01.#{precision}f&quot; % number
   rescue
     number
   end 

   def Convert.mm_to_in(mm, precision=2)
     number_with_precision(mm * 0.03937, precision)
   end 

   def Convert.in_to_mm(inches, precision=2)
     number_with_precision(inches / 0.03937 , precision)
   end 

   def Convert.feet_to_meters(f, precision=2)
     number_with_precision( f * 0.3048, precision)
   end 

   def Convert.meters_to_inches(m, precision=2)
     number_with_precision( m * 39.37, precision)
   end 

   def Convert.meters_to_feet(m, precision=2)
     number_with_precision( m * 3.281, precision)
   end 

   def Convert.kg_to_lbs(kg, precision=2)
     number_with_precision( kg * 2.2   , precision)
   end 

   def Convert.lbs_to_kg(lbs, precision=2)
     number_with_precision( lbs / 2.2   , precision)
   end 

   def Convert.nm_to_inch_pounds(nm, precision=1)
     number_with_precision( nm * 8.850   , precision)
   end 

   def Convert.inch_pounds_to_nm(inlb, precision=1)
     number_with_precision( inlb / 8.850   , precision)
   end 

 end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2008/07/ruby-conversion-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails redirect_to :back in Internet Explorer</title>
		<link>http://ahabman.com/blog/2008/06/rails-redirect_to-back-in-internet-explorer/</link>
		<comments>http://ahabman.com/blog/2008/06/rails-redirect_to-back-in-internet-explorer/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 21:03:12 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=25</guid>
		<description><![CDATA[Today I realized that the rails command redirect_to :back does not work in Internet Explorer because redirect_to :back depends on the HTTP_REFERER http header, which IE does not send. I was capturing an onclick event with jQuery and was able to sending along the current URL as a query string, which provided an easy way [...]]]></description>
			<content:encoded><![CDATA[<p>Today I realized that the rails command   redirect_to :back  does not work in Internet Explorer because  redirect_to :back  depends on the HTTP_REFERER http header, which IE does not send.  I was capturing an onclick event with jQuery and was able to sending along the  current URL as a query string, which provided an easy way around this limitation.</p>
<p>In the view:</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script&gt;
    $jQuery('#myLink').click(function(){
        window.location.href = 'theDestinationPage/?current_url=' + document.location ;
    })
&lt;/script&gt;
</pre>
<p>In the controller:</p>
<pre class="brush: ruby; title: ; notranslate">
def myAction
    .....
    redirect_to params[:current_url]
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ahabman.com/blog/2008/06/rails-redirect_to-back-in-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

