<?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>42 &#187; Rails</title>
	<atom:link href="http://www.42.mach7x.com/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.42.mach7x.com</link>
	<description>Thoughts and tips about programming with Ruby on Rails</description>
	<lastBuildDate>Thu, 09 Sep 2010 09:28:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Rails find case sensitive search</title>
		<link>http://www.42.mach7x.com/2010/05/17/rails-find-case-sensitive-search/</link>
		<comments>http://www.42.mach7x.com/2010/05/17/rails-find-case-sensitive-search/#comments</comments>
		<pubDate>Mon, 17 May 2010 16:14:48 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[BINARY]]></category>
		<category><![CDATA[Case insensitive]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=200</guid>
		<description><![CDATA[Problem You want to use find in Rails for a case sensitive search. For example in your authentication logic you have something to find the user to login as in: u=User.find_by_login(&#8216;username&#8217;) If you don&#8217;t want to limit the available logins with case insensitive validation in the model, then the above code will not work if [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You want to use find in Rails for a case sensitive search. For example in your authentication logic you have something to find the user to login as in:<br />
<span class="code">u=User.find_by_login(&#8216;username&#8217;)</span><br />
If you don&#8217;t want to limit the available logins with case insensitive validation in the model, then the above code will not work if you have &#8216;Username&#8217; and &#8216;username&#8217; as available logins, as the find will only return one of them.</p>
<p><strong>Solution</strong><br />
Change the find method to use the BINARY keyword in your database (only used with MySQL), as in the following:<br />
<span class="code">u=User.find(:first, :conditions => ["BINARY login = ?", login])</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2010/05/17/rails-find-case-sensitive-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NoMethodError (undefined method `refresh_token&#8217; for #):</title>
		<link>http://www.42.mach7x.com/2010/03/26/nomethoderror-undefined-method-refresh_token-for/</link>
		<comments>http://www.42.mach7x.com/2010/03/26/nomethoderror-undefined-method-refresh_token-for/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 15:52:48 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[Mandriva]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=187</guid>
		<description><![CDATA[Problem When you get the above error you cannot login to your application. Solution You will need to delete the cookies for the authentication, so in Firefox (Linux) go to Preferences, remove individual cookies for the specific domain.]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
When you get the above error you cannot login to your application.</p>
<p><strong>Solution</strong><br />
You will need to delete the cookies for the authentication, so in Firefox (Linux) go to Preferences, remove individual cookies for the specific domain.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2010/03/26/nomethoderror-undefined-method-refresh_token-for/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freezing rails to an older version using gems</title>
		<link>http://www.42.mach7x.com/2010/03/15/freezing-rails-to-an-older-version-using-gems/</link>
		<comments>http://www.42.mach7x.com/2010/03/15/freezing-rails-to-an-older-version-using-gems/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 10:43:45 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[2.3.2]]></category>
		<category><![CDATA[freezing]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=178</guid>
		<description><![CDATA[Problem You want to deploy to a shared host (dreamhost) that has a later version of rails from the one you have developed your application. You also have a later version installed in your development pc,and using rake rails:freeze:gems uses the latest one and not the one you want. Solution Use the following to freeze [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You want to deploy to a shared host (dreamhost) that has a later version of rails from the one you have developed your application.<br />
You also have a later version installed in your development pc,and using rake rails:freeze:gems uses the latest one and not the one you want.</p>
<p><strong>Solution</strong><br />
Use the following to freeze the specific version you want, and by using your gems you have installed:<br />
<span class="code">rake rails:freeze:gems VERSION=2.3.2</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2010/03/15/freezing-rails-to-an-older-version-using-gems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freezing gems (other than rails) on 2.3.4</title>
		<link>http://www.42.mach7x.com/2009/09/08/freezing-gems-other-than-rails-on-2-3-4/</link>
		<comments>http://www.42.mach7x.com/2009/09/08/freezing-gems-other-than-rails-on-2-3-4/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 20:17:04 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[2.3.4]]></category>
		<category><![CDATA[freezing]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=132</guid>
		<description><![CDATA[Problem Your host (ie dreamhost) for deploying applications doesn&#8217;t have the gems you are using in your development. Solution After freezing your rails gems with rake rails:freeze:gems, freeze the rest of your gems, not with rake gems:freeze gem=GEM_NAME, as used in previous versions of rails, but with: rake gems:unpack]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
Your host (ie dreamhost) for deploying applications doesn&#8217;t have the gems you are using in your development.</p>
<p><strong>Solution</strong><br />
After freezing your rails gems with rake rails:freeze:gems, freeze the rest of your gems, not with rake gems:freeze gem=GEM_NAME, as used in previous versions of rails, but with:</p>
<p><span class="code">rake gems:unpack</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2009/09/08/freezing-gems-other-than-rails-on-2-3-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails XSS vulnerability</title>
		<link>http://www.42.mach7x.com/2009/09/04/rails-xss-vulnerability/</link>
		<comments>http://www.42.mach7x.com/2009/09/04/rails-xss-vulnerability/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 12:39:16 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[2.3.4]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=129</guid>
		<description><![CDATA[Problem There was a warning about an XSS vulnerability in Ruby on Rails. More details can be found here. Solution Upgrade to the most recent (fixed) Rails version (2.3.4): sudo gem install rails]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
There was a warning about an XSS vulnerability in Ruby on Rails. More details can be found <a href="http://groups.google.com/group/rubyonrails-security/msg/7f57cd7794e1d1b4?pli=1">here</a>.</p>
<p><strong>Solution</strong><br />
Upgrade to the most recent (fixed) Rails version (2.3.4):</p>
<p><span class="code">sudo gem install rails</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2009/09/04/rails-xss-vulnerability/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Phusion Passenger installation in Mandriva 2009</title>
		<link>http://www.42.mach7x.com/2009/01/08/phusion-passenger-installation-in-mandriva-2009/</link>
		<comments>http://www.42.mach7x.com/2009/01/08/phusion-passenger-installation-in-mandriva-2009/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 11:30:53 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[Mandriva]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Passenger]]></category>
		<category><![CDATA[phusion passenger]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=71</guid>
		<description><![CDATA[Problem You have recently installed Mandriva 2009 and you want to install phusion passenger. Solution First make sure that apache is installed. If it is not installed (default), do: urpmi apache On the selection question about the dependencies select option 1 (apache-prefork) Use the details from the phusion passenger website. ie: Install passenger: gem install [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You have recently installed Mandriva 2009 and you want to install phusion passenger.</p>
<p><strong>Solution</strong></p>
<ol>
<li>First make sure that apache is installed. If it is not installed (default), do:
<pre class="code">urpmi apache</pre>
<p>On the selection question about the dependencies select option 1 (apache-prefork)</li>
<li>Use the details from the phusion passenger website. ie:<br />
Install passenger:</p>
<pre class="code">gem install passenger</pre>
</li>
<li>Run the passenger installation:
<pre class="code">passenger-install-apache2-module</pre>
</li>
<li>If at the second stage of the installation the installer complains that <em>GNU C++ compiler &#8230; not found</em>, install the gnu c++ compiler, with:
<pre class="code">urpmi gcc_c++</pre>
</li>
<li>Run the passenger installation (step 3) again. If at this stage the installer complains that <em>Apache 2 development headers &#8230; not found</em>, use:
<pre class="code">urpmi apache-devel</pre>
</li>
<li>Run passenger installer (step 3), once more. Now everything should be ok and the apache 2 module will be installed when the installer finishes.</li>
<li>Restart the Apache webserver, and you should be able to add your Rails application. Use the following to deploy your application in /somewhere/public:
<pre class="code">&lt;VirtualHost *:80&gt;
  ServerName www.yourhost.com
  DocumentRoot /somewhere/public
&lt;/VirtualHost&gt;</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2009/01/08/phusion-passenger-installation-in-mandriva-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>assert_difference and Rails 2.1.0</title>
		<link>http://www.42.mach7x.com/2008/11/25/assert_difference-and-rails-210/</link>
		<comments>http://www.42.mach7x.com/2008/11/25/assert_difference-and-rails-210/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 13:50:17 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[assert_difference]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails 2.1.0]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=67</guid>
		<description><![CDATA[Problem Trying to use the assert_difference with Rails 2.1.0 produces errors if trying to use it with the syntax of another rails version. Solution The correct syntax for using assert_difference with rails 2.1.0 is: def test_should_create_user assert_difference(User, :count, 1) do user = create_user assert !user.new_record?, "#{user.errors.full_messages.to_sentence}" end end]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
Trying to use the assert_difference with Rails 2.1.0 produces errors if trying to use it with the syntax of another rails version.</p>
<p><strong>Solution</strong><br />
The correct syntax for using assert_difference with rails 2.1.0 is:</p>
<pre class="code">def test_should_create_user

assert_difference(User, :count, 1) do

user = create_user

assert !user.new_record?, "#{user.errors.full_messages.to_sentence}"

end

end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2008/11/25/assert_difference-and-rails-210/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 2 new ways</title>
		<link>http://www.42.mach7x.com/2008/05/28/rails-2-new-ways/</link>
		<comments>http://www.42.mach7x.com/2008/05/28/rails-2-new-ways/#comments</comments>
		<pubDate>Wed, 28 May 2008 12:21:28 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[migrations]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby On Rails 2]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=36</guid>
		<description><![CDATA[Problem To get used to the new ways of working with Rails 2. Solution Here are some of the new ways of doing things in Rails 2. Create a scaffold and migration on one step: ./script/generate scaffold product fied1_name:string field2_name:string field3_name:float Make sure that you don&#8217;t have any previous migration(ie manually created) for the same [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
To get used to the new ways of working with Rails 2.</p>
<p><strong>Solution</strong><br />
Here are some of the new ways of doing things in Rails 2.</p>
<ol>
<li>Create a scaffold and migration on one step:
<pre class="code">./script/generate scaffold product fied1_name:string field2_name:string field3_name:float</pre>
<p>  Make sure that you don&#8217;t have any previous migration(ie manually created) for the same model, as the generator will stop and won&#8217;t overwrite the previous migration.
  </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2008/05/28/rails-2-new-ways/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
