<?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>We Heart Code &#187; rails</title>
	<atom:link href="http://www.weheartcode.com/category/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weheartcode.com</link>
	<description>A discourse on programming</description>
	<lastBuildDate>Thu, 12 May 2011 23:17:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Running rails with mongrel for a specific sub directory</title>
		<link>http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/</link>
		<comments>http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/#comments</comments>
		<pubDate>Mon, 10 Sep 2007 13:20:54 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/</guid>
		<description><![CDATA[I've started using mongrel for running rails apps with apache2 and mod_proxy , it works like a charm and allows you to run multiple rails apps and mongrel instances on one server. Your proxy setup looks like this in your httpd.conf or vhost.conf &#60;VirtualHost *:80&#62; &#160; &#160; ServerName myapp.com &#160; &#160; ServerAlias www.myapp.com &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>I've started using <a href="http://mongrel.rubyforge.org/index.html">mongrel</a> for running rails apps with apache2 and mod_proxy , it works like a charm and allows you to run multiple rails apps and mongrel instances on one server.</p>
<p>Your proxy setup looks like this in your httpd.conf or vhost.conf</p>
<div class="syntax_hilite">
<div id="code-3">
<div class="code">&lt;VirtualHost *:<span style="color:#800000;">80</span>&gt;<br />
&nbsp; &nbsp; ServerName myapp.<span style="">com</span><br />
&nbsp; &nbsp; ServerAlias www.<span style="">myapp</span>.<span style="">com</span></p>
<p>&nbsp; &nbsp; ProxyPass /myapp http:<span style="color:#FF9933; font-style:italic;">//www.myapp.com:8000/</span><br />
&nbsp; &nbsp; ProxyPassReverse /myapp http:<span style="color:#FF9933; font-style:italic;">//www.myapp.com:8000</span><br />
&nbsp; &nbsp; ProxyPreserveHost on<br />
&nbsp; &lt;/VirtualHost&gt;</div>
</div>
</div>
<p></p>
<p>Then in your environment.rb add:</p>
<div class="syntax_hilite">
<div id="ruby-4">
<div class="ruby">ActionController::AbstractRequest.<span style="color:#9900CC;">relative_url_root</span> = '/myapp'</div>
</div>
</div>
<p></p>
<p>This will make ActionController rewrite the proper URL for your rails application.</p>
<!-- Social Bookmarks BEGIN --><div class="social_bookmark"><em>Bookmark to:</em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/&amp;title=Running+rails+with+mongrel+for+a+specific+sub+directory" title="Add 'Running rails with mongrel for a specific sub directory' to Del.icio.us"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/delicious.png" title="Add 'Running rails with mongrel for a specific sub directory' to Del.icio.us" alt="Add 'Running rails with mongrel for a specific sub directory' to Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/&amp;title=Running+rails+with+mongrel+for+a+specific+sub+directory" title="Add 'Running rails with mongrel for a specific sub directory' to digg"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/digg.png" title="Add 'Running rails with mongrel for a specific sub directory' to digg" alt="Add 'Running rails with mongrel for a specific sub directory' to digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Running+rails+with+mongrel+for+a+specific+sub+directory&amp;u=http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/" title="Add 'Running rails with mongrel for a specific sub directory' to FURL"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/furl.png" title="Add 'Running rails with mongrel for a specific sub directory' to FURL" alt="Add 'Running rails with mongrel for a specific sub directory' to FURL" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/&amp;title=Running+rails+with+mongrel+for+a+specific+sub+directory" title="Add 'Running rails with mongrel for a specific sub directory' to reddit"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/reddit.png" title="Add 'Running rails with mongrel for a specific sub directory' to reddit" alt="Add 'Running rails with mongrel for a specific sub directory' to reddit" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/" title="Add 'Running rails with mongrel for a specific sub directory' to Technorati"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/technorati.png" title="Add 'Running rails with mongrel for a specific sub directory' to Technorati" alt="Add 'Running rails with mongrel for a specific sub directory' to Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/&amp;title=Running+rails+with+mongrel+for+a+specific+sub+directory" title="Add 'Running rails with mongrel for a specific sub directory' to Google Bookmarks"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/google.png" title="Add 'Running rails with mongrel for a specific sub directory' to Google Bookmarks" alt="Add 'Running rails with mongrel for a specific sub directory' to Google Bookmarks" /></a></div>
<!-- Social Bookmarks END -->]]></content:encoded>
			<wfw:commentRss>http://www.weheartcode.com/2007/09/10/running-rails-with-mongrel-for-a-specific-sub-directory/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Derived Columns in ActiveRecord</title>
		<link>http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/</link>
		<comments>http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/#comments</comments>
		<pubDate>Mon, 16 Oct 2006 23:41:10 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/</guid>
		<description><![CDATA[Sometimes it's useful to have a field in your ActiveRecord implentation that isn't actually selected in your query or present in your table. One way to acheive this is by simply adding a new accessor to your Model class. Let's say we have a table named Customers that has a firstname and lastname column but [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it's useful to have a field in your <a href="http://wiki.rubyonrails.com/rails/pages/ActiveRecord">ActiveRecord</a> implentation that isn't actually selected in your query or present in your table. One way to acheive this is by simply adding a new accessor to your Model class.</p>
<p>Let's say we have a table named Customers that has a firstname and lastname column but we would like to also have a fullname column available to us when doing things like iterating through Customer objects in our view. One way is to add it directly to our Customers class ( app/model/customer.rb in your rails app).</p>
<div class="syntax_hilite">
<div id="ruby-6">
<div class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> Customer &lt;ActiveRecord::Base<br />
<span style="color:#9966CC; font-weight:bold;">def</span> fullname<br />
&nbsp; &nbsp; @fullname = <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">firstname</span> + ' ' + <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">lastname</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div>
</div>
</div>
<p></p>
<!-- Social Bookmarks BEGIN --><div class="social_bookmark"><em>Bookmark to:</em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/&amp;title=Derived+Columns+in+ActiveRecord" title="Add 'Derived Columns in ActiveRecord' to Del.icio.us"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/delicious.png" title="Add 'Derived Columns in ActiveRecord' to Del.icio.us" alt="Add 'Derived Columns in ActiveRecord' to Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/&amp;title=Derived+Columns+in+ActiveRecord" title="Add 'Derived Columns in ActiveRecord' to digg"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/digg.png" title="Add 'Derived Columns in ActiveRecord' to digg" alt="Add 'Derived Columns in ActiveRecord' to digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Derived+Columns+in+ActiveRecord&amp;u=http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/" title="Add 'Derived Columns in ActiveRecord' to FURL"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/furl.png" title="Add 'Derived Columns in ActiveRecord' to FURL" alt="Add 'Derived Columns in ActiveRecord' to FURL" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/&amp;title=Derived+Columns+in+ActiveRecord" title="Add 'Derived Columns in ActiveRecord' to reddit"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/reddit.png" title="Add 'Derived Columns in ActiveRecord' to reddit" alt="Add 'Derived Columns in ActiveRecord' to reddit" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/" title="Add 'Derived Columns in ActiveRecord' to Technorati"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/technorati.png" title="Add 'Derived Columns in ActiveRecord' to Technorati" alt="Add 'Derived Columns in ActiveRecord' to Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/&amp;title=Derived+Columns+in+ActiveRecord" title="Add 'Derived Columns in ActiveRecord' to Google Bookmarks"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/google.png" title="Add 'Derived Columns in ActiveRecord' to Google Bookmarks" alt="Add 'Derived Columns in ActiveRecord' to Google Bookmarks" /></a></div>
<!-- Social Bookmarks END -->]]></content:encoded>
			<wfw:commentRss>http://www.weheartcode.com/2006/10/16/derived-columns-in-activerecord/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

