<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>ahabman</title>
	<atom:link href="http://www.ahabman.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ahabman.com/blog</link>
	<description></description>
	<pubDate>Thu, 16 Oct 2008 13:01:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
		<!-- podcast_generator="podPress/8.8" -->
		<copyright>&#xA9; </copyright>
		<managingEditor>andy@ahabman.com ()</managingEditor>
		<webMaster>andy@ahabman.com()</webMaster>
		<category>music</category>
		<ttl>1440</ttl>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary></itunes:summary>
		<itunes:author></itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name></itunes:name>
			<itunes:email>andy@ahabman.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.ahabman.com/blog/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://www.ahabman.com/blog/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>ahabman</title>
			<link>http://www.ahabman.com/blog</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>ruby on rails - has and belongs to many view plugin</title>
		<link>http://www.ahabman.com/blog/2008/10/ruby-on-rails-has-and-belongs-to-many-view-plugin/</link>
		<comments>http://www.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.
&#60;div id="m2m_container"&#62;
&#60;%= render :partial =&#62; "shared/m2m", :locals =&#62; {
:thing =&#62; @project,
:association [...]]]></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>&lt;div id="m2m_container"&gt;</pre>
<pre>&lt;%= render :partial =&gt; "shared/m2m", :locals =&gt; {</pre>
<pre>:thing =&gt; @project,</pre>
<pre>:association =&gt; 'people',</pre>
<pre>:association_attr =&gt; 'first_name' }   %&gt;</pre>
<pre>&lt;/div&gt;</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://www.ahabman.com/blog/2008/10/ruby-on-rails-has-and-belongs-to-many-view-plugin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>You can&#8217;t use class variables in rails.</title>
		<link>http://www.ahabman.com/blog/2008/10/you-cant-use-class-variables-in-rails/</link>
		<comments>http://www.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 - while running a mass synchronization, and needing to store the timestamp (I [...]]]></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 - 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://www.ahabman.com/blog/2008/10/you-cant-use-class-variables-in-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ruby csv to structured hash</title>
		<link>http://www.ahabman.com/blog/2008/09/ruby-csv-to-structured-hash/</link>
		<comments>http://www.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:
{
'apple'=&#62; { 'color'=&#62;'red',  'flavor'=&#62;'sweet', 'shape'=&#62;'round'},
'banana'=&#62; {  'color'=&#62;'yellow',  'flavor'=&#62;'sweet', 'shape'=&#62;'long'},
'lemon'=&#62; {   'color'=&#62;'yellow',  'flavor'=&#62;'sour', 'shape'=&#62;'round'}
}

So I wrote this, which does the job:
require "faster_csv"

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 &#124;row, i&#124;
		thing = { row[0] =&#62; {} }
			header.each_with_index do &#124;col, header_index&#124;
			thing[ [...]]]></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>{
'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>require "faster_csv"

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://www.ahabman.com/blog/2008/09/ruby-csv-to-structured-hash/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Django Tango</title>
		<link>http://www.ahabman.com/blog/2008/07/django-tango/</link>
		<comments>http://www.ahabman.com/blog/2008/07/django-tango/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 17:21:05 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[music]]></category>

		<category><![CDATA[acoustic]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[grisman]]></category>

		<category><![CDATA[gypsy]]></category>

		<category><![CDATA[jazz]]></category>

		<category><![CDATA[mandolin]]></category>

		<category><![CDATA[tango]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=29</guid>
		<description><![CDATA[A Django Reinhardt and David Grisman fusion.
multitrack mandolins, nylon guitars,  and percusion.
]]></description>
			<content:encoded><![CDATA[<p>A Django Reinhardt and David Grisman fusion.</p>
<p>multitrack mandolins, nylon guitars,  and percusion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/07/django-tango/feed/</wfw:commentRss>
			<enclosure url="http://www.ahabman.com/blog/podpress_trac/feed/29/0/Andy%20Weber%20-%20Django%20Tango.mp3" length="1" type="audio/mpeg"/>
<itunes:duration>00:01:01</itunes:duration>
		<itunes:subtitle>A Django Reinhardt and David Grisman fusion.

multitrack mandolins, nylon guitars,nbsp; and percusion. </itunes:subtitle>
		<itunes:summary>A Django Reinhardt and David Grisman fusion.

multitrack mandolins, nylon guitars,nbsp; and percusion.</itunes:summary>
		<itunes:keywords>music</itunes:keywords>
		<itunes:author>andy@ahabman.com</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:block>No</itunes:block>
	</item>
		<item>
		<title>Ruby conversion module</title>
		<link>http://www.ahabman.com/blog/2008/07/ruby-conversion-module/</link>
		<comments>http://www.ahabman.com/blog/2008/07/ruby-conversion-module/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 12:52:11 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[rails]]></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.
module Convert

  def Convert.number_with_precision(number, precision=2)
    "%01.#{precision}f" % 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 * [...]]]></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>module Convert</pre>
<pre></pre>
<pre>  def Convert.number_with_precision(number, precision=2)</pre>
<pre>    "%01.#{precision}f" % number</pre>
<pre>  rescue</pre>
<pre>    number</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.mm_to_in(mm, precision=2)</pre>
<pre>    number_with_precision(mm * 0.03937, precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.in_to_mm(inches, precision=2)</pre>
<pre>    number_with_precision(inches / 0.03937 , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre></pre>
<pre>  def Convert.feet_to_meters(f, precision=2)</pre>
<pre>    number_with_precision( f * 0.3048, precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.meters_to_inches(m, precision=2)</pre>
<pre>    number_with_precision( m * 39.37, precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.meters_to_feet(m, precision=2)</pre>
<pre>    number_with_precision( m * 3.281, precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.kg_to_lbs(kg, precision=2)</pre>
<pre>    number_with_precision( kg * 2.2   , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.lbs_to_kg(lbs, precision=2)</pre>
<pre>    number_with_precision( lbs / 2.2   , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.nm_to_inch_pounds(nm, precision=1)</pre>
<pre>    number_with_precision( nm * 8.850   , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.inch_pounds_to_nm(inlb, precision=1)</pre>
<pre>    number_with_precision( inlb / 8.850   , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/07/ruby-conversion-module/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails redirect_to :back in Internet Explorer</title>
		<link>http://www.ahabman.com/blog/2008/06/rails-redirect_to-back-in-internet-explorer/</link>
		<comments>http://www.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 HTTP_REFERER, which IE does not do.  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 [...]]]></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 HTTP_REFERER, which IE does not do.  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>&lt;script&gt;</pre>
<pre>    $jQuery('#myLink').click(function(){</pre>
<pre>        window.location.href = 'theDestinationPage/?current_url=' + document.location ;</pre>
<pre>    })</pre>
<pre>&lt;/script&gt;</pre>
<p>In the controller:</p>
<pre>def myAction</pre>
<pre>    .....</pre>
<pre>    redirect_to params[:current_url]</pre>
<pre>end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/06/rails-redirect_to-back-in-internet-explorer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails background process - simple, fast, easy.</title>
		<link>http://www.ahabman.com/blog/2008/05/rails-background-process-simple-fast-easy/</link>
		<comments>http://www.ahabman.com/blog/2008/05/rails-background-process-simple-fast-easy/#comments</comments>
		<pubDate>Sat, 31 May 2008 22:46:12 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=24</guid>
		<description><![CDATA[My situation was this -

Rails 2.0 app running on slicehost (ubuntu 8.04) in passenger mod_rails
The goal was Dynamic PDF generation for a product catalog ( &#62; 100 pages)
This event had to be triggered from within the rails request / response cycle, but run outside of it
I needed the simplest, fastest, more reliable way for this [...]]]></description>
			<content:encoded><![CDATA[<p>My situation was this -</p>
<ul>
<li>Rails 2.0 app running on slicehost (ubuntu 8.04) in <a href="http://www.modrails.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.modrails.com');">passenger mod_rails</a></li>
<li>The goal was <a href="http://ruby-pdf.rubyforge.org/pdf-writer/" onclick="javascript:pageTracker._trackPageview('/outbound/article/ruby-pdf.rubyforge.org');">Dynamic PDF generation</a> for a product catalog ( &gt; 100 pages)</li>
<li>This event had to be triggered from within the rails request / response cycle, but run outside of it</li>
<li>I needed the simplest, fastest, more reliable way for this to happen</li>
</ul>
<p>I looked at <a href="http://backgroundrb.rubyforge.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/backgroundrb.rubyforge.org');">BackgroundRB</a>, it is the most robust, well documented solution available.  But it was overkill since I didn&#8217;t need status feedback and my time was very limited (backgroundRB setup seems somewhat involved).  And, I wasn&#8217;t sure how it would interact with Passenger mod_rails - although <a href="http://github.com/FooBarWidget" onclick="javascript:pageTracker._trackPageview('/outbound/article/github.com');">FooBarWidget</a> mentioned on IRC that it should work as expected.</p>
<p>I looked at <a href="http://hearmesqueak.blogspot.com/2007/09/spawn-background-processing-in-rails.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/hearmesqueak.blogspot.com');">Spawn plugin</a> which supports threading and forking ruby processes.   No luck - setting it one way never ran inside mod_rails and setting it the other way tied up the request response cycle.</p>
<p>All the ruby code was in place, except for how to detach this process from the request/response cycle, when <a href="http://severnspoon.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/severnspoon.com');">severnspoon</a> provided this<br />
<strong>Simple, Easy, One-Line Solution:</strong></p>
<pre>My_Controller</pre>
<pre>  def generate_pdf_in_background
</pre>
<pre>    system " RAILS_ENV=#{RAILS_ENV}   ruby  #{RAILS_ROOT}/script/runner   'MyModel.create_pdf_in_background'  <a href="http://lynx.astro.ku.dk/comp-phys/tutorials/background.shtml" onclick="javascript:pageTracker._trackPageview('/outbound/article/lynx.astro.ku.dk');">&amp;</a> &#8221;
</pre>
<pre>  end</pre>
<pre>end
</pre>
<p>That ampersand was all I needed.  It runs the command as a background process.  A new ruby process is kicked off, and the 10 minute task runs perfectly.  Something makes the browser hang and wait for a response, but we confirmed that other requests can happen along side this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/05/rails-background-process-simple-fast-easy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Point</title>
		<link>http://www.ahabman.com/blog/2008/05/point/</link>
		<comments>http://www.ahabman.com/blog/2008/05/point/#comments</comments>
		<pubDate>Sun, 25 May 2008 20:24:06 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=22</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ahabman.com/blog/wp-content/uploads/2008/05/point.jpg" ><img class="alignnone size-medium wp-image-23" title="point" src="http://www.ahabman.com/blog/wp-content/uploads/2008/05/point.jpg" alt="" width="340" height="453" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/05/point/feed/</wfw:commentRss>
			<enclosure url="http://www.ahabman.com/blog/podpress_trac/feed/22/0/point.mp3" length="1" type="audio/mpeg"/>
<itunes:duration>00:01:01</itunes:duration>
		<itunes:subtitle>Point</itunes:subtitle>
		<itunes:summary></itunes:summary>
		<itunes:keywords>music</itunes:keywords>
		<itunes:author>andy@ahabman.com</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:block>No</itunes:block>
	</item>
		<item>
		<title>mod_rails set RAILS_ENV variable to QA, Staging, or Production</title>
		<link>http://www.ahabman.com/blog/2008/05/mod_rails-set-rails_env-variable-to-qa-staging-or-production/</link>
		<comments>http://www.ahabman.com/blog/2008/05/mod_rails-set-rails_env-variable-to-qa-staging-or-production/#comments</comments>
		<pubDate>Sat, 24 May 2008 01:32:14 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<category><![CDATA[rails mod_rails capistrano]]></category>

		<guid isPermaLink="false">http://www.grandrapidswebdeveloper.com/blog/2008/05/mod_rails-set-rails_env-variable-to-qa-staging-or-production/</guid>
		<description><![CDATA[I&#8217;m using mod_rails with capistrano and multi-stage (qa, staging, production), and wrote this workaround so that the RAILS_ENV could be set correctly in each stage.  Mod_rails sets RAILS_ENV once in the global server conf file, but I needed it set once for each environment: qa, staging, and production.  I tried setting ENV['RAILS_ENV] in each file [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using mod_rails with capistrano and multi-stage (qa, staging, production), and wrote this workaround so that the RAILS_ENV could be set correctly in each stage.  Mod_rails sets <a href="http://www.modrails.com/documentation/Users%20guide.html#rails_env" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.modrails.com');" target="_blank">RAILS_ENV once in the global server conf file</a>, but I needed it set once for each environment: qa, staging, and production.  I tried setting ENV['RAILS_ENV] in each file under config/deploy/ but the setting was not picked up.</p>
<p>Solution - write the correct value into config/environment.rb&#8217;s  ENV[''RAILS_ENV] while deploying.</p>
<p>So here is my 3 step fix -</p>
<p>Step 1.</p>
<p>I created a new file</p>
<p>lib/set_mod_rails_env.rb</p>
<pre># sets ENV['rails_env'] for mod_rails</pre>
<pre># <a href="http://www.megasolutions.net/ruby/search-a-file-and-replace-text-50116.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.megasolutions.net');" target="_blank">http://www.megasolutions.net/ruby/search-a-file-and-replace-text-50116.aspx</a></pre>
<pre># Robert Evans'</pre>
<pre>def ChangeOnFile(file, regex_to_find, text_to_put_in_place)</pre>
<pre>  text = File.read file</pre>
<pre>  File.open(file, 'w+'){|f| f &lt;&lt; text.gsub(regex_to_find,</pre>
<pre>      text_to_put_in_place)}</pre>
<pre>end</pre>
<pre>ChangeOnFile("#{ARGV[0]}/config/environment.rb&#8221;, /#mod_rails_env_here/, &#8220;ENV['RAILS_ENV']=&#8217;#{ARGV[1]}&#8217;&#8221;)</pre>
<p>Step 2.</p>
<p>Add the following code to config/deploy.rb</p>
<pre>namespace :deploy do</pre>
<pre>desc "set ENV['RAILS_ENV'] for mod_rails&#8221;</pre>
<pre>task :before_restart do</pre>
<pre>run "ruby #{current_release}/lib/set_mod_rails_env.rb  #{current_release}  #{stage}"</pre>
<pre>end</pre>
<pre>end</pre>
<p>Step 3.</p>
<p>Add the following code to config/environment.rb</p>
<pre># deploy.rb will swap this out for the appropriate rails_env.</pre>
<pre># mod_rails apparently need this var in this file (not ./environments/qa.rb)</pre>
<pre># do not change the following line. Ruby regexp looks for it.</pre>
<pre>#mod_rails_env_here</pre>
<p>That&#8217;s it.  Let me know if you know of an easier way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/05/mod_rails-set-rails_env-variable-to-qa-staging-or-production/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery validation with Prototype</title>
		<link>http://www.ahabman.com/blog/2008/05/jquery-validation-with-prototype/</link>
		<comments>http://www.ahabman.com/blog/2008/05/jquery-validation-with-prototype/#comments</comments>
		<pubDate>Sat, 17 May 2008 00:27:32 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[prototype]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.grandrapidswebdeveloper.com/blog/?p=3</guid>
		<description><![CDATA[Here is the jQuery validation plugin fixed up so that it works if you have prototype installed along side jQuery.  I just replaced references to $() with jQuery() in the jQuery.validations.js file.
jquery.validate.js with prototype
]]></description>
			<content:encoded><![CDATA[<p>Here is the jQuery validation plugin fixed up so that it works if you have prototype installed along side jQuery.  I just replaced references to $() with jQuery() in the jQuery.validations.js file.<br />
<a href="http://www.grandrapidswebdeveloper.com/blog/wp-content/uploads/2008/05/jqueryvalidate.js" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.grandrapidswebdeveloper.com');">jquery.validate.js with prototype</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/05/jquery-validation-with-prototype/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.868 seconds -->
