<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Paul On Rails</title>
    <link>http://paulonrails.com</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Paul's thoughts on Rails</description>
    <item>
      <title>Quickie irb/console hints</title>
      <description>&lt;p&gt;For some reason I&amp;#8217;m not a big script/console user.  Not really sure why but I normally either work with script/server or by running unit tests.  However script/console and irb are useful tools, here are a few quick hints.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://pablotron.org/software/wirble/"&gt;Wirble&lt;/a&gt; this gem adds in some really nice features to both irb and console.  Specially nice are persistent history, color syntax highlighting and tab completion.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.caliban.org/ruby/rubyguide.shtml#ri"&gt;ri&lt;/a&gt; I have the web interfaces to &lt;a href="http://www.ruby-doc.org/core/"&gt;rdoc&lt;/a&gt; and &lt;a href="http://api.rubyonrails.org/"&gt;api.rubyrails.org&lt;/a&gt; bookmarked.  However this can be more convenient.  Just use &lt;code&gt;ri classname&lt;/code&gt; or &lt;code&gt;ri classname#methodname&lt;/code&gt; to get docs on an object.  As a nice bonus Wirble adds in ri support to irb/console.&lt;/p&gt;


&lt;code&gt;reload!&lt;/code&gt; should reload in all your model changes within console.  This hopefully should reduce the number of times you have to exit out of console.</description>
      <pubDate>Thu, 20 Dec 2007 16:33:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:88b94f80-ea5a-44e7-9d91-bf569a930916</guid>
      <author>Paul Haddad</author>
      <link>http://paulonrails.com/articles/2007/12/20/quickie-irb-console-hints</link>
      <category>Hints</category>
      <category>Hints</category>
      <category>irb</category>
      <category>console</category>
    </item>
    <item>
      <title>in_place_editor_field and multiple element updates</title>
      <description>This one took me a while to figure out so hopefully it'll be useful for someone out there.  I had a fairly simple need, an in_place_editor_field that updates multiple elements.  The main trick here is to make sure the &lt;b&gt;:script =&gt; true&lt;/b&gt; option gets passed in.&lt;br /&gt;
&lt;br /&gt;
In the View do the following
&lt;pre&gt;&amp;lt;%= in_place_editor_field :asset, :name,
 { :id =&amp;gt; &amp;quot;in_place_editor_#{@asset.dom_id}&amp;quot; }, 
:script =&amp;gt; true %&amp;gt;&lt;/pre&gt;

And in the Controller
&lt;pre&gt;
  def set_asset_name
    asset  = Asset.find_by_id(params[:id])
    old_value = asset.name
    asset.name = params[:value]
    asset.name = old_value unless asset.save

    render :update do | page |
      page.replace_html "edit_#{asset.dom_id}", asset.name  
      page.replace_html "in_place_editor_#{asset.dom_id}", asset.name  
    end
  end
&lt;/pre&gt;

Again the key is to make sure the &lt;b&gt;:script =&gt; true&lt;/b&gt; option is set, otherwise you'll get the JS code generated by the render :update instead of the new value.

</description>
      <pubDate>Thu, 29 Nov 2007 17:50:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:b51e3e42-3d27-4c03-af95-d7670568014e</guid>
      <author>Paul Haddad</author>
      <link>http://paulonrails.com/articles/2007/11/29/in_place_editor_field-and-multiple-element-updates</link>
      <category>Code</category>
      <category>Ajax</category>
      <category>in_place_editor_field</category>
      <category>javascript</category>
    </item>
    <item>
      <title>MediaTemple and Rails Part 1, The Install</title>
      <description>&lt;p&gt;So assuming you&amp;#8217;ve ordered a &lt;a href="http://mediatemple.net"&gt;MediaTemple&lt;/a&gt; Dedicated-Virtual Server account and you want to setup a proper rails/mongrel setup you&amp;#8217;ll want to follow the below instructions.&lt;/p&gt;

&lt;p&gt;The first thing you want to do is ask support to make some changes to your machine.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ask them to enable root ssh access&lt;/li&gt;
&lt;li&gt;Ask them to install the Developer Tools on the machine&lt;/li&gt;
&lt;li&gt;(Optional) Ask them to disable Plesk.  I personally don&amp;#8217;t like stuff like Plesk, but some folks do.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Unfortunately, MT was a bit slow at doing all the above so give yourself a day or two for all the above to finish, they&amp;#8217;ll probably need to re-image your server, so wait until they are all finished before you put anything on there. &lt;/p&gt;

&lt;p&gt;For some reason MT doesn&amp;#8217;t install yum as part of their base install, so the next step is to install yum.&lt;/p&gt;

&lt;p&gt;Go to the &lt;a href="http://vault.centos.org/4.4/os/i386/CentOS/RPMS/"&gt;Centos Vault&lt;/a&gt; and download the needed packages.  Should be the following.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;yum-2.4.3-1.c4.noarch.rpm&lt;/li&gt;
&lt;li&gt;python-sqlite-1.1.7-1.2.i386.rpm&lt;/li&gt;
&lt;li&gt;python-elementtree-1.2.6-4.2.1.i386.rpm&lt;/li&gt;
&lt;li&gt;python-urlgrabber-2.9.8-2.noarch.rpm&lt;/li&gt;
&lt;li&gt;sqlite-3.3.3-1.2.i386.rpm&lt;/li&gt;
&lt;li&gt;sqlite-devel-3.3.3-1.2.i386.rpm&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use wget or curl to download these files to a directory and then use &lt;pre&gt;rpm -i *&lt;/pre&gt; to install everything (note make sure you do this as the root user).&lt;/p&gt;

&lt;p&gt;Now that you have yum install you can easily install the right versions of apache and ruby.  First let&amp;#8217;s configure yum to grab new versions of apache from the &lt;a href="http://www.jasonlitka.com/yum-repository/"&gt;Utter Ramblings Repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Create a file in /etc/yum.repos.d called utterramblings.repo and add the following lines to it.&lt;/p&gt;

&lt;pre&gt;
    [utterramblings]
    name=Jason's Utter Ramblings Repo
    baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
&lt;/pre&gt;

&lt;p&gt;Once this is done you should issue a &lt;pre&gt;yum update&lt;/pre&gt; command and let the latest apache and such be updated.  Follow this up with a simple install of ruby 1.8.5 using the CentOS-Testing.repo.&lt;/p&gt;

&lt;p&gt;Create a CentOS-Testing.repo in /etc/yum.repos.d and put the following content in it.&lt;/p&gt;

&lt;pre&gt;
    [c4-testing]
    name=CentOS-4 Testing 
    baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
&lt;/pre&gt;

&lt;p&gt;This time just issue an &lt;pre&gt;yum update ruby&lt;/pre&gt; command.  Edit the CentOS-Testing.repo file and set &lt;pre&gt;enabled=1&lt;/pre&gt; to &lt;pre&gt;enabled=0&lt;/pre&gt; since we don&amp;#8217;t want this particular repository for anything other then this.&lt;/p&gt;

&lt;p&gt;Almost done!  Just follow the &lt;a href="http://www.rubygems.org/read/chapter/3"&gt;RubyGems Installation Instructions&lt;/a&gt; and type in &lt;pre&gt;gem install rails&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;Voila a Rails setup.  You&amp;#8217;ll probably want to add in gems for mysql and such, but at least this should get you going as far as MT is concerned.&lt;/p&gt;</description>
      <pubDate>Tue, 23 Oct 2007 12:38:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:372a1172-5cc1-4566-a2de-8bef41c96368</guid>
      <author>Paul Haddad</author>
      <link>http://paulonrails.com/articles/2007/10/23/mediatemple-and-rails-part-1-the-install</link>
      <category>Hosting</category>
      <category>MediaTemple</category>
      <category>Hosting</category>
      <category>yum</category>
    </item>
    <item>
      <title>soap4r is Evil! Part 2</title>
      <description>&lt;p&gt;So more time wasted on this gem.  Turns out my previous fix didn't work with the console.  The problem is console doesn't seem to load in the boot.rb on startup, at least the irb process doesn't.  Fortunately I was able to come up with a better fix that doesn't depend on modifying boot.rb in anyway.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# this is here for bug http://dev.ctor.org/soap4r/ticket/433#comment:6
 require 'rubygems'
 RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
 Gem.path &amp;lt;&amp;lt; "#{RAILS_ROOT}/vendor/gems"
 Gem.source_index.refresh!
 gem 'soap4r'
# done with hack for http://dev.ctor.org/soap4r/ticket/433#comment:6
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The idea here is pretty much the same as before, the only real difference is the refresh! call which causes the gems to be re-looked at.  The RAILS_ROOT bit is just there because since console doesn't call boot.rb it won't be defined otherwise.&lt;/p&gt;

&lt;p&gt;One more issue I ran into is that on a newly installed machine I didn't have the httpclient gem installed.  So just made sure that was added in my vendors/gems directory and all is good.&lt;/p&gt;</description>
      <pubDate>Mon, 22 Oct 2007 14:54:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:5541e6ae-bb69-4188-a268-2a24ae5d7e9c</guid>
      <author>Paul Haddad</author>
      <link>http://paulonrails.com/articles/2007/10/22/soap4r-is-evil-part-2</link>
      <category>Hacks</category>
      <category>soap4r</category>
      <category>Hack</category>
      <category>workaround</category>
      <category>bug</category>
      <category>sucks</category>
    </item>
    <item>
      <title>soap4r is Evil!</title>
      <description>&lt;p&gt;I was going to talk about setting up rails at MediaTemple, but I just wasted a good portion of yesterday dealing with soap4r.  So I figured I&amp;#8217;d write/vent about that instead.&lt;/p&gt;


	&lt;p&gt;The problem is if soap4r is installed as a gem it tends to kill anything that doesn&amp;#8217;t have &lt;code&gt;require 'soap4r'&lt;/code&gt; installed at the very top of environment.rb.  This is detailed in the this &lt;a href="http://dev.ctor.org/soap4r/ticket/433"&gt;bug&lt;/a&gt;.  Even though its marked as invalid I think the soap4r guys really should do something about it.&lt;/p&gt;


	&lt;p&gt;Anyways until this is fixed and because I didn&amp;#8217;t want to modify some perfectly fine apps, I had to come up with a workaround, perhaps there is a better way to do this, but this is what I came up with.&lt;/p&gt;


	&lt;p&gt;From &lt;span class="caps"&gt;RAILS&lt;/span&gt;_ROOT&lt;/p&gt;


&lt;code&gt;gem install -i vendor/gems soap4r&lt;/code&gt;

	&lt;p&gt;This causes the gem to get installed into vendor/gems.  Note I don&amp;#8217;t think there&amp;#8217;s a way to uninstall the plugin via gem, but for now it&amp;#8217;ll do.&lt;/p&gt;


	&lt;p&gt;Continuing on, I added the following right after the &lt;code&gt;require 'rubygems'&lt;/code&gt; line in boot.rb.&lt;/p&gt;


&lt;code&gt;Gem.path &amp;lt;&amp;lt; "#{RAILS_ROOT}/vendor/gems"&lt;/code&gt;

	&lt;p&gt;and then I just have the standard &lt;code&gt;require 'soap4r'&lt;/code&gt; at the top of requirement.rb.&lt;/p&gt;


	&lt;p&gt;Not what I&amp;#8217;d call the most elegant solution to this problem, but it should work for our env.&lt;/p&gt;</description>
      <pubDate>Fri, 19 Oct 2007 08:00:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:746ef9ed-bc56-4a6a-a453-0a9d1e83c518</guid>
      <author>Paul Haddad</author>
      <link>http://paulonrails.com/articles/2007/10/19/soap4r-is-evil</link>
      <category>Hacks</category>
      <category>soap4r</category>
      <category>Hack</category>
      <category>workaround</category>
      <category>bug</category>
      <category>sucks</category>
    </item>
    <item>
      <title>Hosting Rails Fun or You Get what You Pay For</title>
      <description>&lt;p&gt;I think I'm on my 4th web provider in 3 years.  I started over at &lt;a href="http://he.net"&gt;Hurricane Electric&lt;/a&gt; which is actually a rather decent provider for static content.  They are however a bit expensive so I was lured over to &lt;a href="http://www.dreamhost.com/"&gt;DreamHost&lt;/a&gt;.  Now I know a lot of people dislike DreamHost but for static content its hard to beat them from a feature and price standpoint.&lt;/p&gt;

&lt;p&gt;The problem with Dreamhost started when I went to deploy my first rails app.  This is something I wouldn't recommend for anyone.  Dreamhost just isn't setup to host something like rails, they have very strict monitoring software that kill any long running processes or anything that consumes too much memory.  This pretty much kills Rails so it was time for another move.&lt;/p&gt;

&lt;p&gt;After looking around for quite a bit I settled on &lt;a href="http://www.hostingrails.com"&gt;HostingRails.com&lt;/a&gt; which seemed to be a good choice, for a while.  They had fairly knowledgeable support folks and were able to setup some mongrel instances and a fastcgi instance for me.  I'm not really crazy about their cPanel based control panel, but then I'm not really crazy about any of those control panels.  However HostingRails.com has started getting really problematic lately.  I have offsite monitoring tools running and several times a day my rails site would show as being down, most of the time this was a 10-30 minute problem, however recently I've had at least a couple outings that lasted several hours.  Following up with support wasn't really very useful, it'd take several hours to fix anything and sometimes I didn't even get replies.  The final straw was when for no reason they decided to firewall outgoing packets to my credit card processor.&lt;/p&gt;

&lt;p&gt;After more looking around I switched over to a Virtual Host over at &lt;a href="http://www.mediatemple.net"&gt;MediaTemple&lt;/a&gt;.  I debated going with their Grid Service but saw a few bad reports on it and was tired of risking it.  The Virtual Host setup seems to be pretty good (specially once I had them remove that Plesk stuff).  Their email based support seems glacially slow, but that's about the only complaint I have with them so far.  I've got 4 mongrel instances running across 3 different applications (2 typo blogs and the backend store for &lt;a href="http://pth.com"&gt;PTH&lt;/a&gt;.  Again so far so good, I'm a little concerned that I might be going the memory allocation, but they haven't complained yet.  :^)&lt;/p&gt;

&lt;p&gt;I'll talk some more about how to properly install rails on one of these Centos 4 like boxes in a future blog entry.&lt;/p&gt;</description>
      <pubDate>Thu, 18 Oct 2007 07:35:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:f0b985f7-f5ce-4b05-9dfe-288acf1a5eda</guid>
      <author>Paul Haddad</author>
      <link>http://paulonrails.com/articles/2007/10/18/hosting-rails-fun-or-you-get-what-you-pay-for</link>
      <category>Hosting</category>
      <category>Hosting</category>
      <category>Dreamhost</category>
      <category>HostingRails</category>
      <category>MediaTemple</category>
    </item>
  </channel>
</rss>
