<?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>Wed, 01 Feb 2012 14:38:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using named gemsets with rvm</title>
		<link>http://www.42.mach7x.com/2012/01/31/using-named-gemsets-with-rvm/</link>
		<comments>http://www.42.mach7x.com/2012/01/31/using-named-gemsets-with-rvm/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 13:48:27 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[named gemsets]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rvm]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=464</guid>
		<description><![CDATA[Problem You want to be able to use different gems/rails version for your application after installing the latest rails version, without having to use bundle exec. &#160; Solution You can use the named gemsets with rvm. More instructions are here: http://beginrescueend.com/gemsets/basics/ so you can install two gemsets for example ruby-1.9.3-p0@rails3_0_11 and another with ruby-1.9.3-p0@rails3_2_1 you [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong></p>
<p>You want to be able to use different gems/rails version for your application after installing the latest rails version, without having to use bundle exec.</p>
<p>&nbsp;</p>
<p><strong>Solution</strong></p>
<p>You can use the named gemsets with rvm.</p>
<p>More instructions are here: http://beginrescueend.com/gemsets/basics/</p>
<p>so you can install two gemsets for example ruby-1.9.3-p0@rails3_0_11 and another with ruby-1.9.3-p0@rails3_2_1</p>
<p>you could then do :</p>
<pre class="brush:shell">rvm gemset create rails3_0_11 rails3_2_1

rvm 1.9.3-p0@rails3_0_11
gem install rails -v 3.0.11

rvm 1.9.3-p0@rails3_2_1
gem install rails -v 3.2.1

rvm gemset use rails3_0_11
bundle install</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2012/01/31/using-named-gemsets-with-rvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>setting dynamic event_source in jquery fullcalendar in rails application</title>
		<link>http://www.42.mach7x.com/2011/11/15/setting-dynamic-event_source-in-jquery-fullcalendar-in-rails-application/</link>
		<comments>http://www.42.mach7x.com/2011/11/15/setting-dynamic-event_source-in-jquery-fullcalendar-in-rails-application/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 16:46:28 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[fullCalendar]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=446</guid>
		<description><![CDATA[Problem You would like to use the fullcalendar jquery plugin to be able to display events in your rails application, but you also want to be able to set the eventSources dynamically depending on the path to your view, especially if your view contains a relationship as in the following example: model_a/1/model_b (user/14/comments) Solution Change [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong></p>
<p>You would like to use the fullcalendar jquery plugin to be able to display events in your rails application, but you also want to be able to set the eventSources dynamically depending on the path to your view, especially if your view contains a relationship as in the following example:</p>
<p>model_a/1/model_b (user/14/comments)</p>
<p><strong>Solution</strong></p>
<p>Change your eventSources to be something like the following and using the jQuery.ajaxSettings.url :</p>
<pre class="brush:js"> // a future calendar might have many sources.
    eventSources: [{
      url: jQuery.ajaxSettings.url,
      color: 'orange',
      textColor: 'black',
      ignoreTimezone: false
    }],</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2011/11/15/setting-dynamic-event_source-in-jquery-fullcalendar-in-rails-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveSupport::TimeWithZone comparisons</title>
		<link>http://www.42.mach7x.com/2011/11/03/activesupporttimewithzone-comparisons/</link>
		<comments>http://www.42.mach7x.com/2011/11/03/activesupporttimewithzone-comparisons/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 14:07:23 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[ActiveSupport::TimeWithZone]]></category>
		<category><![CDATA[Date Comparison]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=441</guid>
		<description><![CDATA[Problem You have two dates that you want to compare in your Rails application, which are both ActiveSupport::TimeWithZone. Although they both look identical, when you are trying to compare them for equality (using ==), you get back false as a result. &#160; Solution These dates can have a difference in milliseconds that doesn&#8217;t normally get [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You have two dates that you want to compare in your Rails application, which are both ActiveSupport::TimeWithZone.</p>
<p>Although they both look identical, when you are trying to compare them for equality (using ==), you get back false as a result.</p>
<p>&nbsp;</p>
<p><strong>Solution</strong></p>
<p>These dates can have a difference in milliseconds that doesn&#8217;t normally get displayed. So first of all try to use to_f to see if they really have a difference.</p>
<p>If they do, then you would need to compare them by converting them to integers first as in :</p>
<p>date_a.to_i == date_b.to_i</p>
<p>and you should be getting back true</p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2011/11/03/activesupporttimewithzone-comparisons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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[linux]]></category>
		<category><![CDATA[Mandriva]]></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>
	</channel>
</rss>

