<?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>All Thumbs and No Fingers &#187; rails</title>
	<atom:link href="http://redjamjar.net/tags/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://redjamjar.net</link>
	<description>A bucket for all things by redjamjar</description>
	<lastBuildDate>Thu, 12 Apr 2012 06:05:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Switching a rails app from mySQL 5.1 to postgresql 8.4</title>
		<link>http://redjamjar.net/internet/databases/switching-a-rails-app-from-mysql-5-1-to-postgresql-8-4/</link>
		<comments>http://redjamjar.net/internet/databases/switching-a-rails-app-from-mysql-5-1-to-postgresql-8-4/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 18:13:17 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[dbms]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[switching]]></category>

		<guid isPermaLink="false">http://redjamjar.net/?p=256</guid>
		<description><![CDATA[Switching a rails app across to postgresql became a necessity recently due to the range of licencing and ownership considerations which have affected mySQL recently. Not wanting to be restricted in some way in how I utilise my app I &#8230; <a href="http://redjamjar.net/internet/databases/switching-a-rails-app-from-mysql-5-1-to-postgresql-8-4/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Switching a rails app across to postgresql became a necessity recently due to the range of licencing and ownership considerations which have affected mySQL recently. Not wanting to be restricted in some way in how I utilise my app I decided to investigate using the popular opensource postgresql database.</p>
<p><span id="more-256"></span></p>
<p>Firstly you need to understand how being more standards conformant may affect your application. If you have been avoiding activerecord for perhaps performance reasons in some queries check to make sure they are going to still work the way you expect.</p>
<p><strong>My checklist includes:</strong></p>
<ul>
<li>Text comparisons are now lowercase</li>
<li>Quotes follow the SQL standard and using single quotes not double as mysql accepts</li>
<li>tSearch2 as an alternative to solr and sphinx and its built in</li>
<li>Tests</li>
<li>The knowledge that my app doesn&#8217;t use anything non standard so should just work <img src='http://redjamjar.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ul>
<div><strong>How to install postgresql on Mac OS X Lion:  </strong></div>
<div>Installation is very simple and mostly covered elsewhere but as a quick reference I did the following:</div>
<div>
<ol>
<li>Download and install macports from <a href="http://www.macports.org/install.php">macports</a>. Take the .dmg as this is bar far the easiest option.<br />
From time to time you should run the following once installed to keep everything up to date.</p>
<pre class="brush: bash">sudo port -v selfupdate</pre>
</li>
<li>Open terminal.app</li>
<li>The following commands will install postgresql and postgresql-server
<pre class="brush: bash">sudo port install postgresql84 postgresql84-server</pre>
<p>If like me you want to know where everything is installed use this command:</p>
<pre class="brush: bash">port contents postgresql84</pre>
</li>
<li>If like me you fine the mySQL query browser and workbench useful then install the equivalent for postgresql
<pre class="brush: bash">sudo port install pgAdmin3</pre>
</li>
<li>Once installed you can get on with configuring and using the database.
<pre class="brush: bash">sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb
sudo su postgres -c &#039;/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb&#039;</pre>
</li>
<li>If you create the database folders as postgres and initialise the database with this user they must also own the server process.</li>
<li>Finally start the database
<pre class="brush: bash">/opt/local/lib/postgresql84/bin/postgres -D /opt/local/var/db/postgresql84/defaultdb</pre>
<p>You can now launch pgAdmin3 and connect to your localhost. Macport apps can be found in /Applications/Macports</li>
</ol>
<div><strong>How to get Rails talking to Postgresql</strong></div>
<div>Once you&#8217;ve got a working postgresql server installed its time to setup rails. In my case I was converting an existing rails app which used mySQL. I did the following:</div>
<div>
<ol>
<li>Install Xcode &#8211; this will be required so that you can compile libraries. You already have it installed right?</li>
<li>Install the rails-pg gem.<br />
To accomplish this the gem will need to compile a library so it needs to know where to find the include folder and your architecture.</p>
<pre class="brush: bash">sudo env ARCHFLAGS=&quot;-arch x86_64&quot; gem install pg -- --with-pg-lib=/opt/local/lib/postgresql84/ --with-pg-include=/opt/local/include/postgresql84/</pre>
</li>
<li>Once installed you can now setup your rails application:</li>
<ol>
<li>For a new application based on Rails 3
<pre class="brush: bash">rails new #name_of_app# -d postgres</pre>
</li>
<li>For an existing application edit the following files<br />
Gemfile</p>
<pre class="brush: bash">gem &#039;pg&#039; </pre>
<p>config/database.yml</p>
<pre class="brush: bash">development:
adapter: postgresql
database: appname_development
username: postgres
password:
host: localhost
encoding: UTF8
pool: 5
</pre>
</li>
</ol>
<li>You should now be able to connect to the postgresql server from Rails and work as you would expect to. Its worth looking through the section below for some advice on the differences you should expect between mySQL and Postgresql before you use the system in anger.</li>
</ol>
</div>
</div>
<div><strong>Resources worth looking at:</strong></div>
<div>
<ul>
<li><a href="http://www.postgresql.org/">Postgresql</a> and the d<a title="8.4 Docs" href="http://www.postgresql.org/docs/8.4/interactive/index.html">ocs</a></li>
<li><a href="http://www.pgadmin.org/">pgAdmin3</a> &#8211; UI for Postgresql. See a demo of what can be done in pgAdmin3 thanks to Gary Carter at EnterpriseDB <p><a href="http://www.youtube.com/watch?v=1wvDVBjNDys"><img src="http://img.youtube.com/vi/1wvDVBjNDys/2.jpg"></a></p>
<p><a href="http://www.youtube.com/watch?v=1wvDVBjNDys">Click here</a> to view the video on YouTube.</p>
</li>
<li><a href="http://railsonpostgresql.com/">Railsonpostgresql.com</a> and specifically recommendations on <a href="http://railsonpostgresql.com/2009/09/04/rails-postgresql-and-database-drivers">rails database adapters</a></li>
<li>Why you should <a href="http://awesomeful.net/posts/45-postgresql-rails-and-why-you-should-care">care about postgresql</a> <em>slighlty old but good background</em></li>
<li>Converting from mySQL to <a href="http://en.wikibooks.org/wiki/Converting_MySQL_to_PostgreSQL">postgresql &#8211; Wikibooks: things to know</a></li>
<li><a href="http://www.heroku.com">Heroku</a> support for Postgresql: <a href="http://devcenter.heroku.com/articles/database">Heroku Database Support</a></li>
<li>Lengthy article on stackoverflow on the thread of converting from mySQL to Postgresql: <a href="http://stackoverflow.com/questions/772111/switching-from-mysql-to-postgresql-tips-tricks-and-gotchas">Gotchas</a></li>
</ul>
</div>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Switching+a+rails+app+from+mySQL+5.1+to+postgresql+8.4+http%3A%2F%2Fbit.ly%2FuPoodl" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Switching+a+rails+app+from+mySQL+5.1+to+postgresql+8.4+http%3A%2F%2Fbit.ly%2FuPoodl" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/internet/databases/switching-a-rails-app-from-mysql-5-1-to-postgresql-8-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: How to fix &#8216;rake/rdoctask&#8217; is deprecated. use rdoc/task instead</title>
		<link>http://redjamjar.net/internet/ruby-on-rails/quick-tip-how-to-fix-rakerdoctask-is-deprecated-use-rdoctask-instead/</link>
		<comments>http://redjamjar.net/internet/ruby-on-rails/quick-tip-how-to-fix-rakerdoctask-is-deprecated-use-rdoctask-instead/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 19:00:43 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rdoc]]></category>

		<guid isPermaLink="false">http://redjamjar.net/?p=250</guid>
		<description><![CDATA[If you&#8217;ve recently found rails complaining about the following: rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+) then open up your rakefile.rb and change require &#039;rake/rdoctask&#039; to look like this: require &#039;rdoc/task&#039; and remember to add the following to &#8230; <a href="http://redjamjar.net/internet/ruby-on-rails/quick-tip-how-to-fix-rakerdoctask-is-deprecated-use-rdoctask-instead/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve recently found rails complaining about the following:</p>
<pre class="brush: bash">rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)</pre>
<p>then open up your rakefile.rb and change</p>
<pre class="brush: ruby">
require &#039;rake/rdoctask&#039;
</pre>
<p>to look like this:</p>
<pre class="brush: ruby">
require &#039;rdoc/task&#039;
</pre>
<p> and remember to add the following to your Gemfile</p>
<pre class="brush: ruby">

group :development do
gem &#039;rdoc&#039;

end
</pre>
<p>You may need to run the following on the command line to freshen your gems</p>
<pre class="brush: bash">sudo bundle install</pre>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Quick+Tip%3A+How+to+fix+%E2%80%98rake%2Frdoctask%E2%80%99+is+deprecated.+use+rdoc%2Ftask+instead+http%3A%2F%2Fbit.ly%2FsL29bE" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Quick+Tip%3A+How+to+fix+%E2%80%98rake%2Frdoctask%E2%80%99+is+deprecated.+use+rdoc%2Ftask+instead+http%3A%2F%2Fbit.ly%2FsL29bE" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/internet/ruby-on-rails/quick-tip-how-to-fix-rakerdoctask-is-deprecated-use-rdoctask-instead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: sudo: rake: command not found</title>
		<link>http://redjamjar.net/uncategorized/quick-tip-sudo-rake-command-not-found/</link>
		<comments>http://redjamjar.net/uncategorized/quick-tip-sudo-rake-command-not-found/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 06:58:10 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://redjamjar.net/?p=211</guid>
		<description><![CDATA[To resolve this issue which for me applies to Ubuntu because rake is not in sudo&#8217;s secure paths do the following on the command line sudo ln -s `which rake` /usr/local/bin/ Tweet This PostNo related posts. Related posts brought to &#8230; <a href="http://redjamjar.net/uncategorized/quick-tip-sudo-rake-command-not-found/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>To resolve this issue which for me applies to Ubuntu because rake is not in sudo&#8217;s secure paths do the following on the command line</p>
<pre class="brush: bash">sudo ln -s `which rake` /usr/local/bin/
</pre>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Quick+Tip%3A+sudo%3A+rake%3A+command+not+found+http%3A%2F%2Fbit.ly%2Fth8xgv" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Quick+Tip%3A+sudo%3A+rake%3A+command+not+found+http%3A%2F%2Fbit.ly%2Fth8xgv" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/uncategorized/quick-tip-sudo-rake-command-not-found/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails selection lists</title>
		<link>http://redjamjar.net/internet/ruby-on-rails/rails-selection-lists/</link>
		<comments>http://redjamjar.net/internet/ruby-on-rails/rails-selection-lists/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 18:08:15 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[select_tag]]></category>

		<guid isPermaLink="false">http://redjamjar.net/?p=189</guid>
		<description><![CDATA[Problem: I&#8217;ve got the need to have a list of options presented in a drop down list but I really don&#8217;t mind them being hard coded somewhere (if I did I&#8217;d stuff them in a database table). Fix: Easy I &#8230; <a href="http://redjamjar.net/internet/ruby-on-rails/rails-selection-lists/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong>: I&#8217;ve got the need to have a list of options presented in a drop down list but I really don&#8217;t mind them being hard coded somewhere (if I did I&#8217;d stuff them in a database table).</p>
<p><strong>Fix</strong>: Easy I can add an array of arrays to my model file and them pull them through to the view. In each sub-array the first element in the name displayed, the second is that submitted with the request.</p>
<p><strong>Example</strong>: In the model for my bookings I add booking_status</p>
<pre class="brush: rails">class Booking &lt; ActiveRecord::Base

  BOOKING_STATUS = [
    [&#039;booked&#039;, &#039;booked&#039;],
    [&#039;request&#039;, &#039;request&#039;],
    [&#039;pending&#039;, &#039;pending&#039;],
    [&#039;approved&#039;, &#039;approved&#039;],
    [&#039;not-approved&#039;, &#039;not_approved&#039;],
    [&#039;other&#039;, &#039;other&#039;] ]

end</pre>
<p>In the view I can then include a selection tag which uses each of these items</p>
<pre class="brush: rails">
&lt;%= f.select :status, Booking::BOOKING_STATUS %&gt;
</pre>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+selection+lists+http%3A%2F%2Fbit.ly%2FtpBCbM" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+selection+lists+http%3A%2F%2Fbit.ly%2FtpBCbM" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/internet/ruby-on-rails/rails-selection-lists/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails rapid prototyping &#8211; partials</title>
		<link>http://redjamjar.net/internet/ruby-on-rails/rails-rapid-prototyping-partials/</link>
		<comments>http://redjamjar.net/internet/ruby-on-rails/rails-rapid-prototyping-partials/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 12:01:00 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[partials]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://redjamjar.net/?p=182</guid>
		<description><![CDATA[Rails script generators enable true prototyping from the command line. The simplicity of being able to generate a complete working application within a few commands is wonderful. However I often find that I&#8217;m spending time to ensure some very simple basics are &#8230; <a href="http://redjamjar.net/internet/ruby-on-rails/rails-rapid-prototyping-partials/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Rails script generators enable true prototyping from the command line. The simplicity of being able to generate a complete working application within a few commands is wonderful. However I often find that I&#8217;m spending time to ensure some very simple basics are better than the out of the box offering.</p>
<p>Yes I know I prototyping, yes I know I&#8217;m going to through it away at the end of the day but still there is no need for not making effective use of partials in forms.</p>
<p>Partials within forms makes sure functionality is rapidly updated in both the new and edit actions.</p>
<p>So typically I like to convert:</p>
<pre class="brush: rails">
&lt;h1&gt;Editing booking&lt;/h1&gt;

&lt;% form_for(@booking) do |f| %&gt;
  &lt;%= f.error_messages %&gt;

  &lt;p&gt;
    &lt;%= f.label :event_id %&gt;&lt;br /&gt;
    &lt;%= f.text_field :event_id %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :user_id %&gt;&lt;br /&gt;
    &lt;%= f.text_field :user_id %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :status %&gt;&lt;br /&gt;
    &lt;%= f.text_field :status %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.submit &#039;Update&#039; %&gt;
  &lt;/p&gt;
&lt;% end %&gt;
</pre>
<p>to something which makes much more sense like: </p>
<pre class="brush: rails">
&lt;h1&gt;Editing booking&lt;/h1&gt;

&lt;% form_for(@booking) do |f| %&gt;
  &lt;%= render :partial =&gt; &#039;form&#039;, :locals =&gt; { :f =&gt; f } %&gt;
  &lt;p&gt;
    &lt;%= f.submit &#039;Update&#039; %&gt;
  &lt;/p&gt;
&lt;% end %&gt;
</pre>
<p>I&#8217;d encourage you to do the same and see how it saves you one more piece of hassle. And of course if your using text mate remember ctrl+shift+H will create the partial for you.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+rapid+prototyping+%E2%80%93+partials+http%3A%2F%2Fbit.ly%2FuKdm7o" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+rapid+prototyping+%E2%80%93+partials+http%3A%2F%2Fbit.ly%2FuKdm7o" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/internet/ruby-on-rails/rails-rapid-prototyping-partials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails localisation bug</title>
		<link>http://redjamjar.net/internet/ruby-on-rails/rails-localisation-bug/</link>
		<comments>http://redjamjar.net/internet/ruby-on-rails/rails-localisation-bug/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 07:25:44 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[i8n]]></category>
		<category><![CDATA[localisation]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://redjamjar.net/?p=119</guid>
		<description><![CDATA[I&#8217;ve just gone through the challenge of working out what was wrong with the following piece of code: '/' do %> nil, nchange => 'this.form.submit()'}) %> Our client reported that on a signup page where they choose an alternative language &#8230; <a href="http://redjamjar.net/internet/ruby-on-rails/rails-localisation-bug/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just gone through the challenge of working out what was wrong with the following piece of code:</p>
<pre class="brush:ror"><% form_tag :controller => '/' do %>
				<%= t(:'txt.language') %> <%= select_tag("locale", options_for_select(LOCALES_AVAILABLE, I18n.locale), { :index => nil, <img src='http://redjamjar.net/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nchange => 'this.form.submit()'}) %>
			<% end %>
</pre>
<p>Our client reported that on a signup page where they choose an alternative language it got redirected and they could never reach the page in their native language.</p>
<p>How can this happen you might ask?</p>
<p>Well the request includes some values within the url which are used as a key. Only if the key is valid is the controller allowed to complete the request. The issue is the combining of maintaining the key and switching the language.</p>
<p>As it happens its a very simple fix and was pointed out to me by Juliana.</p>
<pre class="brush:ror"><% form_tag :controller => request.request_uri do %>
				<%= t(:'txt.language') %> <%= select_tag("locale", options_for_select(LOCALES_AVAILABLE, I18n.locale), { :index => nil, <img src='http://redjamjar.net/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nchange => 'this.form.submit()'}) %>
			<% end %>
</pre>
<p>In this fixed second example the alteration for the controller has been updated to direct the language selector to the controller of the current page. The documentation for this suggests that its broken on IIS (really should you be even trying to use this?) in fact I found that the source has had a significant amount of work go into it to work around the issue and even make it work on that webserver. Its a great little solution to ensure that the reloaded page is returned to the user in the state it was with the addition of the correct language. </p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+localisation+bug+http%3A%2F%2Fbit.ly%2FsVTTJb" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+localisation+bug+http%3A%2F%2Fbit.ly%2FsVTTJb" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/internet/ruby-on-rails/rails-localisation-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails &#8211; if I new when I started what I know now?</title>
		<link>http://redjamjar.net/thoughts/rails-if-i-new-when-i-started-what-i-know-now/</link>
		<comments>http://redjamjar.net/thoughts/rails-if-i-new-when-i-started-what-i-know-now/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 06:56:29 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://redjamjar.net/?p=97</guid>
		<description><![CDATA[How would you answer this question? I&#8217;ve been using rails for development of applications for what feels like a long time. I wasn&#8217;t in the pre 1.0 crowd but I did spend many days hacking around in cgi scripts to &#8230; <a href="http://redjamjar.net/thoughts/rails-if-i-new-when-i-started-what-i-know-now/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>How would you answer this question?</p>
<p>I&#8217;ve been using rails for development of applications for what feels like a long time. I wasn&#8217;t in the pre 1.0 crowd but I did spend many days hacking around in cgi scripts to make the website run in apache so I do feel like I&#8217;ve been here a while.</p>
<p>As brackground I came up through C++ operating systems development (loved it), delphi (blah blah), then on to Java (which I never liked) and into web technologies and scripted languages.</p>
<p>My day job doesn&#8217;t allow more than 10-20% of development anymore (by choice). So although I&#8217;m still keen the time is not usually available. Interesting this has quite an impact on way you program.</p>
<p>For one thing change is an issue, changing technology requires great investment just to achieve the simplest of tasks. Something I can not afford.</p>
<p>Rails has always been for me about using a good language to enjoy my craft. For a variety of reasons enjoyment does enable better results. Further the rails stack goes all the way through the systems I need to utilise &#8211; database, ORM, MVC, and client side (javascript + tempaltes). By understanding one language and leveraging the well written information on Rails I avoid needing to care about most other areas.</p>
<p>However the trade off is that sometimes it just can&#8217;t do what you need so some custom javascript or SQL query is required. I&#8217;ve never been particularly strong at either. So that usually gets less of my attention. I break the rules at this point and do what needs to be done to get the job done. Many in the community would disagree with this approach. And I applaude them, they are correct but realities/needs/timescales differ.<em> As yet I&#8217;ve never had a hard time sleeping at night!<br />
</em></p>
<p>In many cases the Agile method of working is excellent. I was slow to value the testing framework built into the system. For a while I played with Selenium (amazing solution) but I have a regularly changing interface and could never get beyond the issue that tests broke because they were out of date (not the application was broken). Shoulda on the other hand has been very helpful as has rcov.</p>
<p>Of course the testing approach when time constrained is brief in some aspects. And not by design. Its just their is no documentation on how to achieve certain things &#8211; e.g. validate a upload dialog can import, parse and process an zip file + manifest. Of course this is domain specific but validation of file uploads is not, and as yet I&#8217;ve not found anything on this.</p>
<p>Google is a strong friend when there is trouble. I&#8217;ve found many articles and blogs to guide me. Although sometimes in the wrong direction &#8211; engines. There coming back and I&#8217;m scared I found them confused and difficult the first time around so I wonder (without a name change) who will be listening?</p>
<p>Would I do it all again: yes. In fact I&#8217;d do more. Its a fantastic stable platform which has I believe shaken up the entire &#8216;intelligent&#8217; web development community along with its cousins DJango I&#8217;m looking at you. I&#8217;m sure that even in these difficult times we&#8217;ll continue to see this is a fertile ground with many innovations and improvements yet to come.</p>
<p>Looking to the future I&#8217;m very aware of the tiny amount of knowledge I have. I&#8217;ve spoken to many in the community who are streets ahead. I wonder if I&#8217;ll ever get to where they are? Do I need to perhaps not, if anything I can say that even with a small amount of knowledge and clear understanding of the principles (which you can pick up very quickly) creating the next application is available to almost any developer.</p>
<p>If only rails could create cross platform desktop applications?</p>
<p><strong><br />
</strong></p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+%E2%80%93+if+I+new+when+I+started+what+I+know+now%3F+http%3A%2F%2Fbit.ly%2FtDE4Hm" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+%E2%80%93+if+I+new+when+I+started+what+I+know+now%3F+http%3A%2F%2Fbit.ly%2FtDE4Hm" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/thoughts/rails-if-i-new-when-i-started-what-i-know-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails &#8211; speaking REST as a mock webservice</title>
		<link>http://redjamjar.net/internet/rails-speaking-to-rest-as-a-mock-webservice/</link>
		<comments>http://redjamjar.net/internet/rails-speaking-to-rest-as-a-mock-webservice/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 11:03:44 +0000</pubDate>
		<dc:creator>Mojo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://2thumbs.wordpress.com/?p=52</guid>
		<description><![CDATA[Finally understood the distinctions between webservices and rest. Now I don&#8217;t mean the theory aspects Roy Fieldings paper adequately explains the concepts and frankly helps a great deal to try to introduce technology which is along the lines of &#8216;less &#8230; <a href="http://redjamjar.net/internet/rails-speaking-to-rest-as-a-mock-webservice/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Finally understood the distinctions between webservices and rest. Now I don&#8217;t mean the theory aspects Roy Fieldings paper adequately explains the concepts and frankly helps a great deal to try to introduce technology which is along the lines of &#8216;less is more&#8217;.</p>
<p><span id="more-53"></span>What I mean is being able to create a service mock up a test script and talk to the server using XML.</p>
<p>Here is an example of creating a new Person:<br />
<code><br />
require 'net/http'</code></p>
<p><code>s = &lt;&lt;-XML</p>
<p>Sarah<br />
Jhummun</p>
<p>XML</p>
<p>Net::HTTP.start('localhost', 3000) do |http|<br />
response = http.post('/people.xml', "#{s}", 'Content-Type' =&gt; 'text/xml')</p>
<p>#Do something with the response.</p>
<p></code></p>
<p><code> puts "Code: #{response.code}"<br />
puts "Message: #{response.message}"<br />
puts "Body:\n #{response.body}"<br />
end<br />
</code></p>
<p>and here is an example of retrieving a list of people:<br />
<code><br />
require 'net/http'</code></p>
<p><code>Net::HTTP.start('localhost', 3000) do |http|<br />
response = http.get('/people/', 'Accept' =&gt; 'text/xml')</p>
<p>#Do something with the response.</p>
<p></code></p>
<p><code> puts "Code: #{response.code}"<br />
puts "Message: #{response.message}"<br />
puts "Body:\n #{response.body}"<br />
end<br />
</code></p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+%E2%80%93+speaking+REST+as+a+mock+webservice+http%3A%2F%2Fbit.ly%2FvXcdWe" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Rails+%E2%80%93+speaking+REST+as+a+mock+webservice+http%3A%2F%2Fbit.ly%2FvXcdWe" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/internet/rails-speaking-to-rest-as-a-mock-webservice/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Localising a rails app &#8211; in 20 mins</title>
		<link>http://redjamjar.net/internet/ruby-on-rails/localising-a-rails-app-in-20-mins/</link>
		<comments>http://redjamjar.net/internet/ruby-on-rails/localising-a-rails-app-in-20-mins/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 09:36:45 +0000</pubDate>
		<dc:creator>Mojo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[localise]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://2thumbs.wordpress.com/2009/02/07/localising-a-rails-app-in-20-mins/</guid>
		<description><![CDATA[I had an existing rails app which has nearly completed and during its development its been upgraded from 1.2 all the way up to 2.2.2. Anyway I sat down with the latest updates and figured that acts_as_paranoid and will_paginate needed &#8230; <a href="http://redjamjar.net/internet/ruby-on-rails/localising-a-rails-app-in-20-mins/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I had an existing rails app which has nearly completed and during its development its been upgraded from 1.2 all the way up to 2.2.2. Anyway I sat down with the latest updates and figured that acts_as_paranoid and will_paginate needed to be altered but beyond that it seems it just worked.<br />
Suffice to say I&#8217;d managed to configure the locales and make heavy use of google translate to begin adding an alternative language.<br />
It is impressive how easily this has come together.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Localising+a+rails+app+%E2%80%93+in+20+mins+http%3A%2F%2Fbit.ly%2FsHr35o" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Localising+a+rails+app+%E2%80%93+in+20+mins+http%3A%2F%2Fbit.ly%2FsHr35o" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/internet/ruby-on-rails/localising-a-rails-app-in-20-mins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 days to complete the showcase</title>
		<link>http://redjamjar.net/internet/3-days-to-complete-the-showcase/</link>
		<comments>http://redjamjar.net/internet/3-days-to-complete-the-showcase/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 07:09:35 +0000</pubDate>
		<dc:creator>Mojo</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://2thumbs.wordpress.com/2008/12/22/3-days-to-complete-the-showcase/</guid>
		<description><![CDATA[Hi So xmas break is coming and I&#8217;ve a long list of things I&#8217;d like to investigate concerning rails. Having written a few apps now and kept up with rails.latest I&#8217;m ready for a serious test of my skills: a &#8230; <a href="http://redjamjar.net/internet/3-days-to-complete-the-showcase/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Hi</p>
<p>So xmas break is coming and I&#8217;ve a long list of things I&#8217;d like to investigate concerning rails.</p>
<p>Having written a few apps now and kept up with rails.latest I&#8217;m ready for a serious test of my skills: a squash ladder in 3 days!</p>
<p>Should be fine its basicly a leader board with the added option of challenging users to games on a date and tracking the score to position each in the ladder.</p>
<p>I&#8217;ll keep u posted of progress!</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=3+days+to+complete+the+showcase+http%3A%2F%2Fbit.ly%2FsogC29" title="Post to Twitter"><img class="nothumb" src="http://redjamjar.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=3+days+to+complete+the+showcase+http%3A%2F%2Fbit.ly%2FsogC29" title="Post to Twitter">Tweet This Post</a></p></div><p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://redjamjar.net/internet/3-days-to-complete-the-showcase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: redjamjar.net @ 2012-05-22 10:09:46 -->
