<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Posts about Rails</title>
    <link>http://wiki.futuretoby.com/tag/rails</link>
    <language>en-us</language>
    <item>
      <title>ActiveRecord Gotcha</title>
      <description>I came across this interesting gotcha while debugging through someone else's rails code. When you set a model's one-to-many attribute(an perhaps other association types as well), let's say:&lt;pre&gt;user.friends = new_friend_list&lt;/pre&gt;&lt;div&gt;It doesn't always set it. As far as I can figure from my blackbox testing, it does an equal check first between the old value and the new value, and then sets only if they are different.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Now, in Ruby's == is easily overridable, you can easily make it do anything you want. It happens that Array#== returns true iff both arrays have the same number of elements and each element in one array is == to the element of the other array in the same position. It also happens that ActiveRecord's base class' == returns true as long as the objects are of the same class and the primary keys equal.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Which brings us to the gotcha of the day. The code in question built an array, say &lt;span class="Apple-style-span" style="font-style: italic;"&gt;new_&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;friend_list&lt;/span&gt;&#160;independently, starting with an id list passed in from a from, finding each &lt;span class="Apple-style-span" style="font-style: italic;"&gt;friend&lt;/span&gt;&#160;in the database and adding them to the array, but, in the meantime, modifying a field in each of the friends, say...&lt;span class="Apple-style-span" style="font-style: italic;"&gt;friend.charma++&lt;/span&gt;. It then goes on to set the &lt;span class="Apple-style-span" style="font-style: italic;"&gt;friends&lt;/span&gt;&#160;attribute in the manner you'd already seen above, and saves &lt;span class="Apple-style-span" style="font-style: italic;"&gt;user&lt;/span&gt;. Well, the &lt;span class="Apple-style-span" style="font-style: italic;"&gt;charma&lt;/span&gt;&#160;field&#160;that was modified in each of the friends retrieved did not get saved, because the set did not happen: the &lt;span class="Apple-style-span" style="font-style: italic;"&gt;new_friend_list &lt;/span&gt;pointed to the same list of friends &lt;span class="Apple-style-span" style="font-style: italic;"&gt;user&lt;/span&gt;&#160;was already associated to.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Hmm..., yeah. Watch out for this one. Debugging this one was not fun. It definitely didn't fit with the principle of least surprise.&lt;/div&gt;</description>
      <pubDate>Fri, 01 May 2009 23:18:36 -0500</pubDate>
      <guid>http://wiki.futuretoby.com/ActiveRecord_Gotcha</guid>
      <author>toby ho</author>
      <link>http://wiki.futuretoby.com/ActiveRecord_Gotcha</link>
    </item>
    <item>
      <title>Redirect 301</title>
      <description>I was looking at Google Analytics today and found that I was getting a bunch of traffic on &lt;a href="Use delicious with chrome"&gt;Use Delicious with Chrome&lt;/a&gt;&#160;as well as some programming/technical articles, but on the wiki.futuretoby.com domain rather than on the tobyho.com domain.&#160;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;For those of you who don't know(probably all of you, because...why would you?), this &lt;span class="Apple-style-span" style="font-style: italic;"&gt;"wiki/blog"&lt;/span&gt; runs the on 2 separate domains, but with a different &lt;span class="Apple-style-span" style="font-style: italic;"&gt;facade&lt;/span&gt;&#160;over each one, if you will. One is for my family/personal stuff, for which most of the content it is intended for has access restrictions. The other is the tobyho.com domain, which I created more recently and is mainly for my public content. But all of the content can be accessed in exactly the same way on either domain.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;So, basically, the former domain is still more visible on the Google search engine than the latter, and so people are coming to my articles on that one, rather than where I &lt;span class="Apple-style-span" style="font-style: italic;"&gt;want&lt;/span&gt;&#160;them to go: tobyho.com.&#160;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;How to fix it? Well, it turns out that for things like this, a 301 redirect(as supposed to a 302) is the way to go. It will tell the search engine that the content has moved permantly, and so prompt it to update its index. The code I ended up putting together was pretty simple:&lt;/div&gt;&lt;pre&gt;    tag_names = @page.tag_names
    if request.host != 'tobyho.com' and
        @page.authors.include?(toby) and 
        not tag_names.include?('family') and 
        (tag_names.include?('programming') or&#160;&lt;/pre&gt;&lt;pre&gt;         tag_names.include?('tech') or&#160;&lt;/pre&gt;&lt;pre&gt;         tag_names.include?('gadgets')) then&lt;/pre&gt;&lt;pre&gt;        headers["Status"] = "301 Moved Permanently"
        redirect_to("http://tobyho.com/#{@page.title_for_link}", :status =&gt; 301)
        return
    end&lt;br&gt;&lt;/pre&gt;&lt;div&gt;So, basically, if a visitor comes to an article from the other domain, I want to redirect to the tobyho.com domain if 1) I am the author, 2) the article is tagged with one of &lt;span class="Apple-style-span" style="font-style: italic;"&gt;programming, tech, and gadgets&lt;/span&gt;&#160;and 3) the article is &lt;span class="Apple-style-span" style="font-style: italic;"&gt;not&lt;/span&gt;&#160;tagged with &lt;span class="Apple-style-span" style="font-style: italic;"&gt;family&lt;/span&gt;. The line:&lt;/div&gt;&lt;pre&gt;headers["Status"] = "301 Moved Permanently"  &lt;br&gt;&lt;/pre&gt;&lt;div&gt;Is not needed if you're on a newer version of rails, for which setting &lt;span class="Apple-style-span" style="font-style: italic;"&gt;:status =&gt; 301&lt;/span&gt;&#160;on the next line would suffice. I embarrassed to say that I am still on 1.2.x.&lt;/div&gt;</description>
      <pubDate>Sun, 19 Apr 2009 17:34:36 -0500</pubDate>
      <guid>http://wiki.futuretoby.com/Redirect_301</guid>
      <author>toby ho</author>
      <link>http://wiki.futuretoby.com/Redirect_301</link>
    </item>
    <item>
      <title>Setting up Phusion Passenger on my slice</title>
      <description>As my slice is running low on memory, running multiply mongrel processes really isn't an option any more(I am too cheap to pay for more memory, in these trying economic times). Phusion passenger comes to the rescue!&#160;Phusion passenger is exactly what the rails community needed for its deployment story.&#160;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;So I follow the instructions:&lt;/div&gt;&lt;pre&gt;gem install passenger&lt;br&gt;&lt;/pre&gt;&lt;div&gt;When I did this my slice just hung indefinitely. It turns out that when gem updates the index of ruby gems, it downloads the entire index and puts it in memory, and this didn't fit in my tiny 256m I had on my slice.&#160;&lt;a href="http://www.mail-archive.com/rubygems-developers@rubyforge.org/msg00925.html"&gt;This thread&lt;/a&gt;&#160;ended up saving the day for me. I was able to do:&lt;/div&gt;&lt;pre&gt;gem install passenger -B 1000000&lt;br&gt;&lt;/pre&gt;&lt;div&gt;it was slow but it worked.&lt;/div&gt;&lt;div&gt;Next up was installing the apache2 module:&lt;/div&gt;&lt;pre&gt;passenger-install-apache2-module&lt;br&gt;&lt;/pre&gt;&lt;div&gt;First, it failed to find my apache2 installation and asked my to install it. I told it where it was by doing:&lt;/div&gt;&lt;pre&gt;export APXS2=/usr/local/apache2/bin/apxs&lt;br&gt;&lt;/pre&gt;&lt;div&gt;Next, it didn't find the Apache Portable Runtime(APR). I told it where it was by doing:&lt;/div&gt;&lt;pre&gt;export APR_CONFIG=/usr/local/apache2/bin/apr-1-config&lt;br&gt;&lt;/pre&gt;&lt;div&gt;Then, it didn't find the APU(whatever that is, I stopped caring). I did:&lt;/div&gt;&lt;pre&gt;export APU_CONFIG=/usr/local/apache2/bin/apu-1-config&lt;br&gt;&lt;/pre&gt;&lt;div&gt;After all that, and running passenger-install-apache2-module again, it worked!&#160;&lt;/div&gt;&lt;div&gt;Next I setup the virtual host entries. I created the file /usr/local/apache2/conf/apps/tobyho.conf with these contents:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&amp;lt;VirtualHost *:80&gt;&lt;br&gt;&lt;/pre&gt;&lt;pre&gt;&#160;&#160; &#160; &#160; &#160;ServerName tobyho.com&lt;br&gt;&lt;/pre&gt;&lt;pre&gt;&#160;&#160; &#160; &#160; &#160;DocumentRoot /var/www/apps/mywiki/public&lt;br&gt;&lt;/pre&gt;&lt;pre&gt;&#160;&#160; &#160; &#160; &#160;&amp;lt;Directory "/var/www/apps/mywiki/public"&gt;&lt;br&gt;&lt;/pre&gt;&lt;pre&gt;&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Options FollowSymLinks&lt;br&gt;&lt;/pre&gt;&lt;pre&gt;&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;AllowOverride None&lt;br&gt;&lt;/pre&gt;&lt;pre&gt;&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Order allow,deny&lt;br&gt;&lt;/pre&gt;&lt;pre&gt;&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Allow from all&lt;br&gt;&lt;/pre&gt;&lt;pre&gt;&#160;&#160; &#160; &#160; &#160;&amp;lt;/Directory&gt;&lt;br&gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/VirtualHost&gt;&lt;br&gt;&lt;/pre&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;And now I got the wiki running on mod_rails. Yea!&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;</description>
      <pubDate>Mon, 05 Jan 2009 23:47:26 -0600</pubDate>
      <guid>http://wiki.futuretoby.com/Setting_up_Phusion_Passenger_on_my_slice</guid>
      <author>toby ho</author>
      <link>http://wiki.futuretoby.com/Setting_up_Phusion_Passenger_on_my_slice</link>
    </item>
    <item>
      <title>Turbogears and ReML</title>
      <description>I followed the Turbogears 20 minute tutorial &lt;a href="http://docs.turbogears.org/1.0/Wiki20/Page1" mce_href="http://docs.turbogears.org/1.0/Wiki20/Page1"&gt;here&lt;/a&gt;. The first impressions of Turbogears are:&lt;br&gt;&lt;ol&gt;&lt;li&gt;It's a bit more verbose than rails: there's more plumbing - you have to explicitly define which view you want to use for each action, as supposed to doing everything based on convention.&lt;br&gt;&lt;/li&gt;&lt;li&gt;you explicitly pass the local variables to the view as a hash, as supposed to using class or global variables&lt;/li&gt;&lt;li&gt;Turbogears uses a template engine called kid by default, which is very different from rails' erb in philosophy, there's more emphesis on designer friendliness and higher level support for template inheritence&lt;/li&gt;&lt;li&gt;Python/Turbogears in general is safer than ruby/rails - &lt;a href="http://wiki.futuretoby.com/Ruby:%20Extremely%20Unsafe" mce_href="http://wiki.futuretoby.com/Ruby:%20Extremely%20Unsafe"&gt;see my last post&lt;/a&gt;, in that you usually get more informative errors, such as &lt;font color="#808080" face="courier new,courier"&gt;NameError: global name 'pag' is not defined&lt;/font&gt; rather than &lt;font color="#808080" face="courier new,courier"&gt;nil when you didn't expect it&lt;/font&gt;&lt;/li&gt;&lt;li&gt;The development feedback is not &lt;i&gt;quite &lt;/i&gt;as good as rails. Turbogears requires a restart everytime you make a change. The restart is automatically triggered everytime you save a file in the project, and it is very fast, but it still takes about 5 seconds to rails' 0(ruby has this luxury because of its open classes)&lt;br style=""&gt;&lt;/li&gt;&lt;/ol&gt;I am hip to Haml so I had to see if I could get it working with Turbogears. I found a couple of implementations: &lt;a href="http://reml.wikidot.com/documentation" mce_href="http://reml.wikidot.com/documentation"&gt;ReML&lt;/a&gt; and &lt;a href="http://lucumr.pocoo.org/cogitations/2008/02/15/ghrml-haml-for-genshi/" mce_href="http://lucumr.pocoo.org/cogitations/2008/02/15/ghrml-haml-for-genshi/"&gt;GHRML&lt;/a&gt;. Tried them both, ReML was simpler and more approachable, so I wrote a &lt;a href="http://docs.turbogears.org/1.0/TemplatePlugins" mce_href="http://docs.turbogears.org/1.0/TemplatePlugins"&gt;Turbogears plugin&lt;/a&gt; for it. The important bit of the plugin code is here:&lt;br&gt;&lt;br&gt;&lt;font color="#808080" face="courier new,courier"&gt;from reml import TemplateLoader&lt;/font&gt;&lt;font color="#808080"&gt;&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;font color="#808080" face="courier new,courier"&gt;class RemlTg(object):&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp; def __init__(self, extra_vars_func=None, options=None):&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;br&gt;&lt;br&gt;&amp;nbsp; def load_template(self, templatename):&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Find a template specified in python 'dot' notation."&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; parts = templatename.split('.')&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return TemplateLoader('/'.join(parts[0:len(parts)-1])).load(parts[len(parts)-1] + '.reml')&lt;br&gt;&lt;br&gt;&amp;nbsp; def render(self, info, format="html", fragment=False, template=None):&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Renders the template to a string using the provided info."&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return self.load_template(template).render(info)&lt;/font&gt;&lt;br&gt;&lt;br&gt;After that, I converted the views in the tutorial into ReML. Let me do a wc on them for comparison, wait just a minute...&lt;br&gt;&lt;br&gt;&lt;font color="#808080" face="courier new,courier"&gt;$ wc wiki20/templates/*.kid&lt;br&gt;&amp;nbsp; 25&amp;nbsp;&amp;nbsp; 76 1068 wiki20/templates/edit.kid&lt;br&gt;&amp;nbsp; 71&amp;nbsp; 173 2802 wiki20/templates/master.kid&lt;br&gt;&amp;nbsp; 21&amp;nbsp;&amp;nbsp; 56&amp;nbsp; 773 wiki20/templates/page.kid&lt;br&gt;&amp;nbsp; 21&amp;nbsp;&amp;nbsp; 50&amp;nbsp; 705 wiki20/templates/pagelist.kid&lt;br&gt;&amp;nbsp;138&amp;nbsp; 355 5348 total&lt;br&gt;airport@wedding-singer ~/documents/play/turbogears/Wiki-20&lt;br&gt;$ wc wiki20/templates/*.reml&lt;br&gt;&amp;nbsp; 16&amp;nbsp;&amp;nbsp; 41&amp;nbsp; 492 wiki20/templates/edit.reml&lt;br&gt;&amp;nbsp; 38&amp;nbsp;&amp;nbsp; 86 1338 wiki20/templates/master.reml&lt;br&gt;&amp;nbsp; 12&amp;nbsp;&amp;nbsp; 30&amp;nbsp; 327 wiki20/templates/page.reml&lt;br&gt;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp; 24&amp;nbsp; 190 wiki20/templates/pagelist.reml&lt;br&gt;&amp;nbsp; 74&amp;nbsp; 181 2347 total&lt;/font&gt;&lt;br&gt;&lt;br&gt;So that's about a 50% code reduction, not bad. Here's a Sample for comparison:&lt;br&gt;&lt;br&gt;&lt;b&gt;page.kid:&lt;/b&gt;&lt;br&gt;&lt;font color="#808080" face="courier new,courier"&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:py="http://purl.org/kid/ns#"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; py:extends="'master.kid'"&amp;gt;&lt;br&gt;&amp;lt;head&amp;gt;&lt;br&gt;&amp;lt;title&amp;gt; ${page.pagename} - 20 Minute Wiki &amp;lt;/title&amp;gt;&lt;br&gt;&amp;lt;/head&amp;gt;&lt;br&gt;&amp;lt;body&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="main_content"&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div style="float:right; width: 10em"&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Viewing &amp;lt;span py:replace="page.pagename"&amp;gt;Page Name Goes Here&amp;lt;/span&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;br/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You can return to the &amp;lt;a href="/"&amp;gt;FrontPage&amp;lt;/a&amp;gt;.&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div py:replace="XML(data)"&amp;gt;Page text goes here.&amp;lt;/div&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;p&amp;gt;&amp;lt;a href="${tg.url('/edit', pagename=page.pagename)}"&amp;gt;Edit this page&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&amp;lt;/html&amp;gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;page.reml&lt;/b&gt;&lt;br&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#808080"&gt;- append('master.reml')&lt;br&gt;- def title():&lt;br&gt;&amp;nbsp; =page.pagename&lt;br&gt;- def content():&lt;br&gt;&amp;nbsp; %div: 'style':'float:right; width: 10em'&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Viewing&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %span=page.pagename&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; You can return to the&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %a: 'href':tg.url('/')&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Frontpage&lt;br&gt;&amp;nbsp; %div=unescaped(data)&lt;br&gt;&amp;nbsp; %a: 'href':tg.url('/edit', pagename=page.pagename)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Edit this page&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;br&gt;&lt;/font&gt;</description>
      <pubDate>Thu, 20 Mar 2008 10:10:00 -0500</pubDate>
      <guid>http://wiki.futuretoby.com/Turbogears_and_ReML</guid>
      <author>toby ho</author>
      <link>http://wiki.futuretoby.com/Turbogears_and_ReML</link>
    </item>
    <item>
      <title>capistrano and deprec</title>
      <description>I got slicehost recently to host osspinions, and started getting into using capistrano and deprec to deploy the app and set up the box. You can think of capistrano as a remote control enabled make, and deprec as bunch of tasks build on capistrano that automates the setting up of everything from your user account to deploying your rails app - for ubuntu only. I was really impressed, just 4 commands installed everything up to the rails stack. But the deployment of the app was harder, a lot harder, in fact. I had to install ferret(which I just more recently ditched), FreeImage for image science, and rcov as a gem, and ruby-openid as a gem as well. These things are the ones that I could not stuff into the vendor directory and have it work. After that, for ferret I had to use symlinks to share the index directory, and for uploaded files I had to symlink them too because the deprec setup is such that every deployment you do creates a brand new directory for the new release. This is good in many ways, but it also creates some complications. I heard the guys on the &lt;a href="http://blog.slicehost.com/articles/category/podcast"&gt;slicehost podcast&lt;/a&gt; talk about this and they pretty much confirmed as much: it's hard to make deprec work for everybody because everybody does things differently, Oh well. Capistrano, on the other hand, is pretty nice. I wrote a python script at my last job to build and deploy a Java app, and if I had came across capistrano then, I would have definitely used it instead and would have saved me a lot of work.&lt;br&gt;</description>
      <pubDate>Tue, 26 Feb 2008 23:25:07 -0600</pubDate>
      <guid>http://wiki.futuretoby.com/capistrano_and_deprec</guid>
      <author>toby ho</author>
      <link>http://wiki.futuretoby.com/capistrano_and_deprec</link>
    </item>
    <item>
      <title>Gigantic Rails Log File Slows Down App</title>
      <description>My Wiki has been mysterious getting slower and slow and I didn't have a clue why. Today I happened to check the log file's size, it was over 10m. So I removed it and the Wiki was back to normal. Conclusion: you have to have a way to manage the size of rails applications. Some people just turn off logging altogether. I opted to set the log level to error. Another option would be to have a cron job remove the file periodically.&lt;br&gt;&lt;br&gt;&lt;i&gt;Update: Not so sure the large log file was the cause anymore. I still don't know what caused it, may a memory leak of some sort, or maybe this is just the woes of using a shared host. The problem hasn't come back so far, so I haven't been able to look further.&lt;/i&gt;&lt;br&gt;</description>
      <pubDate>Thu, 21 Feb 2008 18:22:49 -0600</pubDate>
      <guid>http://wiki.futuretoby.com/Gigantic_Rails_Log_File_Slows_Down_App</guid>
      <author>toby ho</author>
      <link>http://wiki.futuretoby.com/Gigantic_Rails_Log_File_Slows_Down_App</link>
    </item>
    <item>
      <title>Changing the rendering for displaying exceptions</title>
      <description>I just added autofresh support for the stacktrace pages, now you get get the benefits of autofresh while you are refactoring your code, which can cause temporary breakage, for example. It was easy, altough not at first easy to find. The answer was found in the comments of actionpack/lib/action_controller/rescue.rb. It bascially said you just need to override the rescue_action_in_public - for "public" errors - and rescue_action_locally - for local errors, which shows the stacktraces. I just copied the existing rescue_action_locally method over and swapped in my template file instead(changed code in orange):&lt;br&gt;&lt;br&gt;&lt;font face="courier new,courier"&gt;module ActionController&lt;br&gt;&amp;nbsp; class Base&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def rescue_action_locally(exception)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; render :text =&amp;gt; 'it bombed'&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; add_variables_to_assigns&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @template.instance_variable_set("@exception", exception)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @template.instance_variable_set("@rescues_path", File.dirname(rescues_path("stub")))&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @template.send!(:assign_variables_from_controller)&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @template.instance_variable_set("@contents", @template.render_file(template_path_for_local_rescue(exception), false))&lt;br&gt;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response.content_type = Mime::HTML&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; render_for_file("&lt;font color="#ff6600"&gt;&lt;b&gt;#{File.dirname(__FILE__)}/templates/layout.erb&lt;/b&gt;&lt;/font&gt;", response_code_for_rescue(exception))&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br&gt;&amp;nbsp; end&lt;br&gt;end&lt;br&gt;&lt;br&gt;&lt;/font&gt;This will tell it to find the layout.erb in my plugin directory instead of the one buried deep inside rails.&lt;font face="courier new,courier"&gt;&lt;br&gt;&lt;/font&gt;</description>
      <pubDate>Fri, 04 Jan 2008 09:30:02 -0600</pubDate>
      <guid>http://wiki.futuretoby.com/Changing_the_rendering_for_displaying_exceptions</guid>
      <author>toby ho</author>
      <link>http://wiki.futuretoby.com/Changing_the_rendering_for_displaying_exceptions</link>
    </item>
    <item>
      <title>Autofresh</title>
      <description>Out of frustration with the work I was doing, I decided to switch gears a tiny bit and work on this idea I had, and &lt;a href="http://autofresh.rubyforge.org/" mce_href="http://autofresh.rubyforge.org/"&gt;Autofresh&lt;/a&gt; was the result. I enjoyed this experiment, it did not take much to make it work - I just based it on the rspec_autotest plugin by Nick Sieger, but it turned out to be very useful, Yeh!&lt;br&gt;</description>
      <pubDate>Thu, 03 Jan 2008 21:35:49 -0600</pubDate>
      <guid>http://wiki.futuretoby.com/Autofresh</guid>
      <author>toby ho</author>
      <link>http://wiki.futuretoby.com/Autofresh</link>
    </item>
  </channel>
</rss>

