<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>rubyisbeautiful - main</title>
  <id>tag:rubyisbeautiful.com,2009:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://rubyisbeautiful.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://rubyisbeautiful.com/" rel="alternate" type="text/html"/>
  <updated>2009-07-01T15:54:25Z</updated>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2009-07-01:441</id>
    <published>2009-07-01T15:53:00Z</published>
    <updated>2009-07-01T15:54:25Z</updated>
    <link href="http://rubyisbeautiful.com/2009/7/1/moved" rel="alternate" type="text/html"/>
    <title>Moved!</title>
<content type="html">
            Please steer over to artofobjects.com, where I will be migrating the articles, new postings, software, etc..
Thanks!
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2009-01-28:381</id>
    <published>2009-01-28T19:07:00Z</published>
    <updated>2009-01-28T19:09:13Z</updated>
    <link href="http://rubyisbeautiful.com/2009/1/28/overhaul" rel="alternate" type="text/html"/>
    <title>overhaul</title>
<content type="html">
            I have not added much to the website recently because it is going through an overhaul.  I am replacing Mephisto with a custom app which simplifies very basic asset uploading, ad management and article posting.  Should be ready shortly.  Thanks for your patience.
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-10-09:209</id>
    <published>2008-10-09T18:22:00Z</published>
    <updated>2008-10-09T18:25:53Z</updated>
    <category term="ruby,rails,plugin,resource_helper"/>
    <link href="http://rubyisbeautiful.com/2008/10/9/updates-to-resource_helper" rel="alternate" type="text/html"/>
    <title>updates to resource_helper</title>
<content type="html">
            &lt;p&gt;resource_helper is currently a Rails plugin that exists to make ActiveResource more compatible with ActiveRecord as well as add some additional functionality.
I made some big changes recently, check it out on &lt;a href=&quot;http://github.com/rubyisbeautiful/resource_helper/tree/master&quot;&gt;github&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-10-03:195</id>
    <published>2008-10-03T14:06:00Z</published>
    <updated>2008-10-03T14:19:38Z</updated>
    <category term="ruby,rails,rake,test,unit"/>
    <link href="http://rubyisbeautiful.com/2008/10/3/grr-rake-and-test-unit-errors" rel="alternate" type="text/html"/>
    <title>Grr! rake and Test::Unit errors</title>
<content type="html">
            &lt;p&gt;This was one of those bugs that was just killing me.  I absolutely could not figure out why some of my new shiny rake tasks were failing.  I went through the motions of uninstalling my custom ruby and rails on my Mac and upgrading instead the system installed Ruby then reinstalling rails and all gems.&lt;/p&gt;


	&lt;p&gt;It was a lot of work, and actually I produced a neato script to help clean gems.  (maybe I&#8217;ll post it up here soon)&lt;/p&gt;


	&lt;p&gt;But it didn&#8217;t fix the situation.  Several hours of google and forum threads that were only somewhat related, I stumbled on an old Rails bug, wherein &#8220;require &#8216;test/unit&#8217;&#8221; was being called by something or other.  Of course it should only be called when testing and when needed.  But it was unfortunately being called on &lt;span class=&quot;caps&quot;&gt;EVERY&lt;/span&gt; rake task after anything that was called.  The problem was that rake was passing the arguments to Test::Unit::AutoRunner which returned errors and generally hosed the parsing of the rake outcome (which is what I was up to).&lt;/p&gt;


	&lt;p&gt;Anyhoo, here is my workaround.  Quick and dirty, but works.  CaveatL only use if you are &lt;span class=&quot;caps&quot;&gt;NOT&lt;/span&gt; using Test::Unit for anything good. (i.e. you still haven&#8217;t switched to rspec &lt;sup&gt;_&lt;/sup&gt; )  Or use the second method listed and control the monkey patch a bit.&lt;/p&gt;


	&lt;p&gt;It can be used in 1 of two ways, I prefer the latter as it gives more control.&lt;/p&gt;


&lt;ol&gt;
 &lt;li&gt;Add the module below to the project&#8217;s main Rakefile&lt;/li&gt;
 &lt;li&gt;Add a file to lib called &#8220;_rake_helper.rb&#8221; and paste the module in there.&lt;/li&gt;
&lt;/ol&gt;

For 2., use it in any Rakefile needing to avoid the Test::Unit clash by requiring it
&lt;pre&gt;
&lt;code&gt;
 require 'lib/tasks/_rake_helper'
 include RakeHelper
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Here is the module:&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
 module Test
   module Unit
     class FakeAutoRunner
       class &amp;lt;&amp;lt;self
         def run
           return true
         end
       end
     end
     begin
       silence_warnings do
         const_set(&quot;AutoRunner&quot;, FakeAutoRunner)
       end
     rescue
     end
   end
 end
&lt;/code&gt;
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-09-05:162</id>
    <published>2008-09-05T21:52:00Z</published>
    <updated>2008-09-05T21:54:46Z</updated>
    <category term="ruby,rails"/>
    <link href="http://rubyisbeautiful.com/2008/9/5/many-updates" rel="alternate" type="text/html"/>
    <title>many updates</title>
<content type="html">
            &lt;p&gt;Lots of updates to the application_configurator plugin.  Check it out on git http://github.com/rubyisbeautiful/application_configurator/wikis&lt;/p&gt;


	&lt;p&gt;Also, some rake tasks for refactoring our migrations, on pastie for sake http://pastie.org/266855
do stuff like check for tables with no models, models with no tables, etc&#8230;&lt;/p&gt;


	&lt;p&gt;rake refactor:db          # Refactor the database with migrations
rake refactor:models   # Look for models with no matching table
rake refactor:schema   # Look for tables in the schema that don&#8217;t exist
rake refactor:tables     # Look for tables that have no matching models&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-08-23:96</id>
    <published>2008-08-23T21:19:00Z</published>
    <updated>2008-09-05T21:43:28Z</updated>
    <category term="ruby,rails,plugin,resource_helper"/>
    <link href="http://rubyisbeautiful.com/2008/8/23/released-resource_helper-plugin" rel="alternate" type="text/html"/>
    <title>released: resource_helper plugin</title>
<content type="html">
            &lt;p&gt;A very basic version of resource_helper as Rails plugin only is &lt;a href=&quot;http://github.com/rubyisbeautiful/resource_helper/tree/master&quot;&gt;live on github&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-08-13:76</id>
    <published>2008-08-13T12:21:00Z</published>
    <updated>2008-09-05T21:44:23Z</updated>
    <category term="ruby,rails,plugin,resource_helper"/>
    <link href="http://rubyisbeautiful.com/2008/8/13/resource_helper-plugin" rel="alternate" type="text/html"/>
    <title>resource_helper plugin</title>
<content type="html">
            &lt;p&gt;I am about to release resource_helper plugin.  I wrote in while working on my client&#8217;s project and it has become invaluable to our team.  It attempts to bridge the small gaps between &lt;a href=&quot;http://api.rubyonrails.org/classes/ActiveRecord/Base.html&quot;&gt;ActiveRecord&lt;/a&gt; and &lt;a href=&quot;http://api.rubyonrails.org/classes/ActiveResource/Base.html&quot;&gt;ActiveResource&lt;/a&gt; and make them &lt;a href=&quot;http://en.wikipedia.org/wiki/Duck_typing&quot;&gt;quack&lt;/a&gt; nearly the same.  It also adds some convenience methods which I found myself rewriting for every new ActiveResource.
I hope to release it by the end of the day today.&lt;/p&gt;


	&lt;p&gt;Update: &lt;a href=&quot;http://github.com/rubyisbeautiful/resource_helper/tree/master&quot;&gt;plugin released on github&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-05-06:74</id>
    <published>2008-05-06T15:10:00Z</published>
    <updated>2008-09-05T21:44:43Z</updated>
    <category term="ruby,rails,god"/>
    <link href="http://rubyisbeautiful.com/2008/5/6/god-config-unrud-un-rude-unfortunately-named-ruby-update-daemon" rel="alternate" type="text/html"/>
    <title>god config: Unrud (*un-rude: unfortunately-named ruby update daemon)</title>
<content type="html">
            &lt;p&gt;Hehe, my new acronym for god.&lt;/p&gt;


	&lt;p&gt;The config suggestion I posted earlier works in theory, but I was having some trouble getting it to work &lt;strong&gt;from init&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;What I ended up having to do was add &lt;pre&gt;&lt;code&gt;sleep&lt;/code&gt;&lt;/pre&gt; after some steps of the god init.  Multiple sub-config loading from a main config file just wasn&#8217;t going to work.  I&#8217;m am sure there is a better way, but this works for the time being, until I have more free time to work on Unrud itself.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
# v.0.0.3
# cobbled by Bryan Taylor http://rubyisbeautiful.com
# god - Start/stop/check Unrud via init 
#
# chkconfig: - 85 15
# description: http://god.rubyforge.org/
# processname: god
# config: /etc/god.conf

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = &quot;no&quot; ] &#38;&#38; exit 0

[ -x /usr/bin/god ] || exit 0

RETVAL=0
prog=&quot;god&quot; 

start() {
# Start daemon only
echo -n $&quot;Starting $prog: &quot; 
/usr/bin/god
sleep 5
  RETVAL=$?
  [ $RETVAL -eq 0 ] &#38;&#38; {
     touch /var/lock/subsys/$prog
     success $&quot;$prog&quot; 
  }
  echo

#load the configs
if [ -e /u/apps/content/current/config/content.god ] ; then
  echo -n $&quot;Loading content config: &quot; 
  /usr/bin/god load /u/apps/content/current/config/content.god
  echo -n $&quot;Loading admin config: &quot; 
  /usr/bin/god load /u/apps/admin/current/config/admin.god
  sleep 5
  RETVAL=$?
  [ $RETVAL -eq 0 ] &#38;&#38; {
     touch /var/lock/subsys/$prog
     success $&quot;$prog&quot; 
   }
   echo
else
  RETVAL=1
fi
return $RETVAL  
}

stop() {
    # Stop daemons.
    echo -n $&quot;Shutting down $prog: &quot; 
    /usr/bin/god quit &#38;
        sleep 5
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] &#38;&#38; rm -f /var/lock/subsys/$prog
    return $RETVAL
}

reload() {
    echo -n &quot;$reloading $prog config: &quot; 
        /usr/bin/god load /u/apps/content/current/config/content.god
        /usr/bin/god load /u/apps/admin/current/config/admin.god
}

# See how we were called.
case &quot;$1&quot; in
    start)
      start
      ;;
    stop)
      stop
      ;;
        reload)
            reload
        ;;
    restart)
      stop
      start
      ;;
    status)
      /usr/bin/god status
      RETVAL=$?
      ;;
    *)
      echo &quot;Usage: god {start|stop|reload|restart|status}&quot; 
      exit 1
  ;;
esac      
exit $RETVAL

&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Also, I modified the init script a little, as god doesn&#8217;t quite behave like a typical *nix daemon.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-05-05:73</id>
    <published>2008-05-05T11:36:00Z</published>
    <updated>2008-05-06T14:04:03Z</updated>
    <category term="merb,git,ruby,osx,mac"/>
    <link href="http://rubyisbeautiful.com/2008/5/5/git-via-gem-temporarily-broken" rel="alternate" type="text/html"/>
    <title>git via gem temporarily broken - FIXED</title>
<content type="html">
            &lt;p&gt;Update:&lt;/p&gt;


	&lt;p&gt;via &lt;a href=&quot;http://twitter.com/ivey&quot;&gt;Twitter from Ivey&lt;/a&gt;: updates pushed to rubyforge.&lt;/p&gt;


	&lt;p&gt;I just checked and all is well; still, follow the advice below to get using git.&lt;/p&gt;


	&lt;p&gt;If you follow the merb core development, you&#8217;ll see that Ivey pushed 0.9.3 gems.  Unfortunately it appears temporarily broken via the default install from rubyforge.  For now, if you haven&#8217;t already hooked up to github and merb, now is the perfect time.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
&amp;gt; git clone git://github.com/wycats/merb-core.git
&amp;gt; cd merb-core
&amp;gt; rake install
&amp;gt; cd ..
&amp;gt; git clone git://github.com/wycats/merb-more.git
&amp;gt; cd merb-more
&amp;gt; rake install

&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-05-03:70</id>
    <published>2008-05-03T00:24:00Z</published>
    <updated>2008-05-03T01:01:16Z</updated>
    <category term="ruby,rails,god"/>
    <link href="http://rubyisbeautiful.com/2008/5/3/the-unfortunately-name-ruby-monitor-god" rel="alternate" type="text/html"/>
    <title>the unfortunately named ruby monitor "god"</title>
<content type="html">
            &lt;p&gt;However poor the taste of the author in choosing a name, it is indeed a great way to monitor, nay, control pretty much anything.&lt;/p&gt;


	&lt;p&gt;I use god on my local dev box (mac) as well to keep all things developery running.&lt;/p&gt;


	&lt;p&gt;I got the init script from http://ezinearticles.com/?Why-Rails-Developers-Need-God&#38;id=845672 and all the good info from http://god.rubyforge.org/&lt;/p&gt;


	&lt;p&gt;Handily, a god init script will of course start your mongrels et al when properly configured.  Here is how I use a config template for the many gods-mongrels&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
host = `hostname`
app = &quot;foo&quot; 

case
when host =~ /theproductionbox/
  ports = %w{ 6400 6401 } 
  RAILS_ROOT = &quot;/u/apps/#{app}/current&quot; 
  shared_path = &quot;/u/apps/#{app}/shared&quot; 
  mongrel_cmd = &quot;/usr/local/bin/ruby /usr/local/bin/mongrel_rails&quot; 
  pid_dir = &quot;#{shared_path}/pids&quot; 
  log_file = &quot;#{shared_path}/log/mongrel.log&quot; 
  uid = 'production_guy'
  gid = uid
  ENV['RAILS_ENV'] ||= 'production'
  rails_env ||= ENV['RAILS_ENV']
  http_host = &quot;fancy.productionbox.com&quot; 
  http_path = &quot;/&quot; 
  http_code = &quot;200&quot; 
when host =~ /somedevbox/
  ports = %w{ 6400 } 
  RAILS_ROOT = &quot;/u/apps/#{app}&quot; 
  shared_path = &quot;/u/apps/#{app}&quot; 
  mongrel_cmd = &quot;/usr/local/bin/ruby /usr/local/bin/mongrel_rails&quot; 
  pid_dir = &quot;#{shared_path}/tmp/pids&quot; 
  log_file = &quot;#{shared_path}/log/mongrel.log&quot; 
  uid = 'development_guy'
  gid = uid
  ENV['RAILS_ENV'] ||= 'development'
  rails_env ||= ENV['RAILS_ENV']
  http_host = &quot;ratbike.devbox.com&quot; 
  http_path = &quot;/&quot; 
  http_code = &quot;200&quot; 
end

ports.each do |port|
  God.watch do |w|
    w.group = app
    w.uid = uid
    w.gid = gid
    w.name = &quot;#{app}-mongrel-#{port}&quot; 
    w.interval = 30.seconds
    w.start = &quot;#{mongrel_cmd} start -d -a 0.0.0.0 -p #{port} -P #{pid_dir}/dispatch.#{port}.pid -e #{rails_env} -c #{RAILS_ROOT} -l #{log_file}&quot; 
    w.stop = &quot;#{mongrel_cmd} stop -P #{pid_dir}/dispatch.#{port}.pid&quot; 
    w.start_grace = 30.seconds
    w.restart_grace = 30.seconds
    w.pid_file = File.join(pid_dir, &quot;dispatch.#{port}.pid&quot;)

    w.behavior(:clean_pid_file)

    w.transition(:init, { true =&amp;gt; :up, false =&amp;gt; :start }) do |on|
      on.condition(:process_running) do |c|
        c.running = true
      end
    end

    w.transition([:start, :restart], :up) do |on|
      on.condition(:process_running) do |c|
        c.running = true
      end
      on.condition(:tries) do |c|
        c.times = 5
        c.transition = :start
      end
    end

    w.transition(:up, :start) do |on|
      on.condition(:process_exits)
    end  

    w.transition(:up, :restart) do |on|
      on.condition(:memory_usage) do |c|
        c.interval = 60.seconds
        c.above = 57.megabytes
        c.times = [4, 5]
      end
      on.condition(:cpu_usage) do |c|
        c.interval = 60.seconds
        c.above = 10.percent
        c.times = [3, 5]
      end
      on.condition(:http_response_code) do |c|
        c.host = http_host
        c.path = http_path
        c.code_is_not = http_code
        c.timeout = 30.seconds
    c.interval = 30.minutes
      end
    end

    # lifecycle
    w.lifecycle do |on|
      on.condition(:flapping) do |c|
        c.to_state = [:start, :restart]
        c.times = 5
        c.within = 5.minute
        c.transition = :unmonitored
        c.retry_in = 10.minutes
        c.retry_times = 5
        c.retry_within = 2.hours
      end
    end
  end
end

God::Contacts::Email.message_settings = {
  :from =&amp;gt; 'god@rubyisbeautiful.com'
}

God::Contacts::Email.server_settings = {
  #settings
}

God.contact(:email) do |c|
  c.name = 'bryan'
  c.email = 'bryan@rubyisbeautiful.com'
end
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-04-24:69</id>
    <published>2008-04-24T14:24:00Z</published>
    <updated>2008-05-03T00:24:09Z</updated>
    <category term="xml,ruby,rails,errors"/>
    <link href="http://rubyisbeautiful.com/2008/4/24/making-errors-better" rel="alternate" type="text/html"/>
    <title>making errors better</title>
<content type="html">
            &lt;p&gt;First, I haven&#8217;t written in awhile.  Like many bloggers that I follow, success in one area diminishes my capacity in other areas.  My contracting business is doing very well.  More than that however, I don&#8217;t like to waste space or mince words on my blog, as you have already noticed.  I won&#8217;t write unless I have something that I think is worth sharing; I won&#8217;t write just to keep a fresh article in the feeds.&lt;/p&gt;


	&lt;p&gt;I have been doing a &lt;strong&gt;lot&lt;/strong&gt; of debugging &#8211; mostly of the needle-in-a-haystack variety.  Simultaneously I am working on a new, re-engineered version of the legacy app I am debugging.  So I have the opportunity to do some things &#8220;right&#8221; this time (I didn&#8217;t write the legacy app, and the developer who did is &lt;span class=&quot;caps&quot;&gt;AWESOME&lt;/span&gt; and a friend.  I am not criticizing the code here.  What always happens is the problems and business rules become clearer as the project matures, giving rise to an opportunity to craft a better model)&lt;/p&gt;


	&lt;p&gt;There are of course great plugins to do some of this, and more.  I personally have found that in some cases less is more and projects that rely to heavily on 3rd party code may end up paying for at debug time.&lt;/p&gt;


	&lt;p&gt;Here are some tweaks to errors and whatnot that I use:&lt;/p&gt;


1. extend StandardError with a simple to_xml method, for use in ActiveResource and pretty much anywhere:
&lt;pre&gt;&lt;code&gt;
class StandardError
  def to_xml
    return &amp;lt;&amp;lt;-ENDOFDOC
      &amp;lt;error type='#{self.class.to_s}'&amp;gt;
        &amp;lt;message&amp;gt;#{message}&amp;lt;/message&amp;gt;
      &amp;lt;/error&amp;gt;
    ENDOFDOC
  end
end
&lt;/code&gt;&lt;/pre&gt;

1.5.  &lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;: I also added a status method, since I use resources so heavily. 
&lt;pre&gt;&lt;code&gt;
@status=400 #its never the server's fault
attr_accessor :status
&lt;/code&gt;&lt;/pre&gt;
and in the custom errors mentioned below, change as needed:
&lt;pre&gt;&lt;code&gt;
LocalApplication::SomeParameterIsMissing.new.status # =&amp;gt; 406
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This works nicely for StandardError and any descendent classes that don&#8217;t already have a to_xml method.  For ActiveRecord:: and some other error classes, there is a to_xml which will override this one.&lt;/p&gt;


2.  put a general error handler in ApplicationController
&lt;pre&gt;&lt;code&gt;

def handle_error(err=nil)
  begin
    if err.nil?
      @error = GenericNilError.new(&quot;Oops, something happened...&quot;)
    else
      @error = err
    end
    respond_to do |flavah|
      flavah.xml { render :xml =&amp;gt; @error.to_xml, status =&amp;gt; 500 and return false }
      flavah.html  # a template for error
    end
  rescue StandardError =&amp;gt; e
    # some failsafe that hits a static
    render :nothing =&amp;gt; true, :status =&amp;gt; 500 and return false
  end
end
&lt;/code&gt;&lt;/pre&gt;

3.  use local errors
As in the example above, roll your own errors.  Then you respond in customized ways.  If you&#8217;re not already rescuing different kinds of errors and handling them in unique ways, you may want to explore that.
&lt;pre&gt;&lt;code&gt;
module LocalApplicationError
  class GenericError &amp;lt; StandardError ; end
  class ShouldNeverHappenError &amp;lt; StandardError ; end
  # etc...
end
&lt;/code&gt;&lt;/pre&gt;

4. have an error log
So much better than scrolling through #{RAILS_ENV}.log
&lt;pre&gt;&lt;code&gt;
err_logger = Logger.new #customize how you want it
[ActiveRecord ActiveResource ActionController].each do |mod|
  mod.module_eval &amp;lt;&amp;lt;- ENDOFMONKEY
    include LocalApplicationError #why not throw this in there too, see #3 above
    @err_logger = err_logger
    mattr_reader :err_logger
  ENDOFMONKEY
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;5. Use specs so you don&#8217;t raise unknown errors!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-03-31:67</id>
    <published>2008-03-31T15:29:00Z</published>
    <updated>2008-03-31T15:30:19Z</updated>
    <category term="merb"/>
    <link href="http://rubyisbeautiful.com/2008/3/31/new-sites-for-merb-docs" rel="alternate" type="text/html"/>
    <title>new sites for merb docs</title>
<content type="html">
            &lt;p&gt;I recently created &lt;a href=&quot;http://merbdoc.com&quot;&gt;merbdoc.com&lt;/a&gt; (a.k.a. &lt;a href=&quot;http://merbapi.com&quot;&gt;merbapi&lt;/a&gt;) to help the Merb community out.  Let me know how if its useful, or how I can improve it.  Its brand new, so it might be down for the next day or so.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-03-25:66</id>
    <published>2008-03-25T12:23:00Z</published>
    <updated>2008-03-25T16:05:59Z</updated>
    <category term="ruby,rails,xml"/>
    <link href="http://rubyisbeautiful.com/2008/3/25/rendering-xml-by-default-or-anything-but-html-in-rails-2" rel="alternate" type="text/html"/>
    <title>rendering xml by default (or anything but html) in rails 2</title>
<content type="html">
            &lt;p&gt;Here&#8217;s a very easy way to change the default render format.  Its not necessarily the best way for you.  Consider that rendering &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; is hardcoded in the code and it is probably default in the browser/client&#8217;s Accept header.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;rails/action_pack/lib/action_view/base.rb&lt;/code&gt;&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
when parameter_format.blank? &#38;&#38; accept_format != :js
          @template_format = :html

&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;For my usage, the best way to change was to add a method to &lt;code&gt;application.rb&lt;/code&gt; and call it as a before filter (either by default in &lt;code&gt;application.rb&lt;/code&gt; or as needed in each controller)
(updated to a better way)&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
protected
def set_request_header
    xml_string = 'application/xml'
    request.instance_eval(&quot;@accepts=Mime::Type.lookup('#{xml_string}')&quot;)
    request.headers['HTTP_ACCEPT']  = xml_string
    request.env['HTTP_ACCEPT']      = xml_string
end

&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;it&#8217;s not really &#8220;playing nice&#8221; but it works and is easy to debug and undo&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-03-21:65</id>
    <published>2008-03-21T08:56:00Z</published>
    <updated>2008-03-21T08:56:43Z</updated>
    <category term="ruby,rails"/>
    <link href="http://rubyisbeautiful.com/2008/3/21/and-now-for-a-break" rel="alternate" type="text/html"/>
    <title>and now for a break</title>
<content type="html">
            &lt;p&gt;Its Spring Break, which means nothing to me other than that my kids are home from school.  Work is difficult.  This week instead of carelessly crafter semi-digested thoughts on Ruby et al., I bring you a picture from &lt;a href=&quot;http://shanti.railsblog.com&quot;&gt;railsblog&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://shanti.railsblog.com/assets/2007/10/24/singleton_lolcat.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyisbeautiful.com/">
    <author>
      <name>bryan</name>
    </author>
    <id>tag:rubyisbeautiful.com,2008-03-13:64</id>
    <published>2008-03-13T12:11:00Z</published>
    <updated>2008-03-13T13:23:02Z</updated>
    <category term="ruby,rails,bash,mac,osx"/>
    <link href="http://rubyisbeautiful.com/2008/3/13/quick-tip-bash-profile" rel="alternate" type="text/html"/>
    <title>quick tip: bash profile</title>
<content type="html">
            If you use a Unix-like development environment, this may be helpful.  Here's some snippets from my .bash_profile on Leopard.


&lt;pre&gt;&lt;code&gt;

function wo {
  cd &quot;/Users/bryan/apps/$1&quot;;
}
function devcon {
 eval script/console $1;
}
function testcon {
 eval &quot;script/console test $1&quot;;
}
function prodcon {
 eval &quot;script/console production -s $1&quot;;
}
function prodcon_live {
 eval &quot;script/console production $1&quot;;
}

&lt;/code&gt;&lt;/pre&gt;

So I get something to go to a certain project I'm working on and use the console quickly.

&lt;pre&gt;&lt;code&gt;

bash:~&gt; wo merb-core
bash:/Users/bryan/apps/lazy_developer&gt; devcon
&gt;&gt;

&lt;/code&gt;&lt;/pre&gt;


It saves a lot of typing.
          </content>  </entry>
</feed>
