This blog has been moved to www.ricroberts.com, so I could host it on Typo.
This post explains how I imported all my old blogger posts into the new typo installation.
Note that the feed has remained the same: feeds.feedburner.com/richtext.
Tuesday, 27 May 2008
Moved to Typo!
Please also visit the Swirrl blog
Posted by Richard Roberts at Tuesday, May 27, 2008 0 comments
Labels: Typo
Friday, 23 May 2008
Read More About Swirrl
As I mentioned a while back, my current project is 'Swirrl'.
Swirrl helps you store, share, edit and analyze the information you need to run your business. It's like a wiki, but better.
Recently I've been putting together some more information on what Swirrl does and why you might want to use it. Please take a look at the new Swirrl home page and Read More page.
There's also a registration form where you can leave your e-mail address if you want to be notified when we are ready to accept sign-ups. We’ll also announce it on the Swirrl blog if there's any other news on progress.
Thanks!
Please also visit the Swirrl blog
Posted by Richard Roberts at Friday, May 23, 2008 0 comments
Labels: swirrl
Friday, 14 March 2008
Lighting your campfire with fluid
Inspired by blog posts from Robby Russell, and thoughtbot, we've recently started using Campfire for
text-chat between our distributed Swirrl team members.
As we all use macs, we were previously using Apple's iChat, with aim/.mac accounts. However, we often had connectivity problems with this, and so I went on the lookout for something new.
Although Campfire doesn't let you display a 'status', we use the idea that if you're in the chat room then you're available for chatting, and if you're not, then you're either away or don't want to be disturbed. This works fine for us. One major benefit of Campfire is that the transcripts of all chats are stored on the server for easy searching.
As is usual for a 37 signals application, The user interface is clean and intuitive. If you're on a mac, the user experience can be further enhanced by using fluid. Fluid lets you create what it calls "Site Specific Browsers". These are bascially uber-bookmarks that you can put in your dock, and let you launch a site in its own little browser as if it was a standalone app.
When using fluid, if you have any unread messages in a chat it handily shows up the dock icon (the image for which can be downloaded here).
If a conversation gets too complicated for text-chat, we still resort to an iChat voice chat, for the reasons described in this old post. iChat also offers the benefit of screen-sharing if you're on Leopard.
Please also visit the Swirrl blog
Posted by Richard Roberts at Friday, March 14, 2008 2 comments
Wednesday, 12 March 2008
Brightbox Rails Hosting
I recently wrote about Swirrl's choice of Rails host, Brightbox, on the Swirrl Blog.
You can read what I had to say here.
Please also visit the Swirrl blog
Posted by Richard Roberts at Wednesday, March 12, 2008 0 comments
Thursday, 6 March 2008
Rails on Mac OS X Leopard
We'll get to the instructions for setting up rails on Leopard in a moment, but first a bit of background...
A few days after it was released, I changed over to using Mac OS X 10.5 (Leopard) as my platform for developing rails apps. When I first installed Leopard it took me a little while to figure out the best way to do things, as Leopard comes with lots of rails development features pre-installed.
Recently, after reinstalling my OS, I had to figure some of it out again as I hadn't made enough notes. So this time, I thought I'd document it properly and share it on my blog for the benefit of others (and so I don't forget too!).
As you might remember from this post last year, I'm a fan of using Netbeans for my rails IDE. Since that post, it has come out of beta and is now a fully fledged release (currrently at v6.0.1).
However, I couldn't get its step-through debugger to work with Leopard's installation of rails. I think is is because Netbeans assumes certain relative paths between the ruby interpreter and your gems, which differ in the Leopard standard install.
After being inspired by this post by Robby Russell, I decided to use Macports as my solution. Macports gives you a self contained environment for installing stuff. Everything installed under Macports lives in /opt/local, so if you mess up your Macports environment, you can easily just trash this folder and start again.
Installation Procedure
Here goes... The following instructions walk you through how to set up a development environment with Ruby, Rails, MySQL, Netbeans and Subversion on OS X 10.5 "Leopard".
Xcode
Before doing anything else, we need to install the Xcode tools from the Leopard DVD. Just double click on the installer and away it goes.
Macports
Download the installer from the Macports site, and run it.
(I used the dmg for v1.5.0 for OS X 10.5, but I think v1.6.0 is out now so you might want to try that one).
MySQL
Now, for MySQL, I just downloaded the package from the MySQL site, and installed it.
The problem I've found with this using this package is that the preference pane and automatic startup item don't work quite right, but there are workarounds for this. In particular, this worked for me:
"[...] the working MySQL.prefPane is here
and to get the StartupItem to work (see bug#25008), copy the (if existent)
/usr/local/MySQLCOM directory to /Library/StartupItems/MySQLCOM "
There are also some great free GUI tools available on the MySQL site too. At the time of writing, there isn't a dedicated package for these available for OS X 10.5 -only 10.4, but it works fine.
Set paths
This step is important! Dont skip it.
edit ~/.bash_profile, for example using TextMate:
mate ~/.bash_profile
and add the following line:
export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
(As I mentioned before, anything installed in Macports is installed under opt/local)
Save the file, and restart your terminal session to pick up the changes.
Install ruby and rubygems in Macports
sudo port install ruby
sudo port install rb-rubygems
Install all your required gems
For example:
sudo gem install rake
sudo gem install rails
sudo gem install capistrano
sudo gem install termios
sudo gem install mongrel
sudo gem install mongrel_cluster
sudo gem install ruby-debug
sudo gem install ruby-debug-ide
(The ruby-debug and ruby-debug-ide gems above are required if you want step-through debugging to work in Netbeans).
Subversion
I just use the subversion installation that comes with Leopard, as this works fine.
Netbeans
Download Netbeans from here, and run the installer. (For developing rails apps, you just need the 'ruby' bundle).
Debgging in Netbeans
In Netbeans, under Preferences->Ruby, set the ruby interpreter to /opt/local/bin/ruby
The fast debugger radio button should become available - select it.
That's pretty much it. You should now have a fully functioning setup for developing on rails.
Note: I use svn over ssh to access my subversion code repository. Below are some instructions for getting this to work with Netbeans. You can safely ignore all that follows if this doesn't apply to you - Netbeans works fine 'out of the box' with svn over http...
svn+ssh in Netbeans
In order to get the svn+ssh protocol to work with Netbeans, you need to set up a ssh key, and set your mac up to remember it. Here's how to do this
1. Create a pair of keys on your local machine.
From your home directory on your mac, run the following command:
ssh-keygen -t dsa
This will prompt you for a secret passphrase - make sure to use a good passphrase. When this is done you will get two files called id_dsa and id_dsa.pub in your ~/.ssh dir.
2. On your server, ensure that the .ssh directory exists for the user
Log in to your server via ssh
ssh myuser@myserver.net
make a .ssh hidden directory
mkdir ~/.ssh
3. Place your public key on your server
On your mac, run
ssh myuser@myserver.net 'cat >>.ssh/authorized_keys' <~/.ssh/id_dsa.pub
4. Try to log in to the server
ssh myuser@myserver.net
You will be asked for the passphrase
In OS X Leopard, there is a user interface for ssh-agent which will ask you if you want to remember the passphrase, and will store it in your keychain. From then on, you wont need to enter a password or a passphrase for this user.
5. Edit the subversion config
This step is required because, although when you check out from an svn repository in Netbeans, the dialog asks you for a tunnel command, it forgets that when you restart the IDE.
On your mac, edit the ~/.subversion/config file (note: this file wont exist unless you've previously run Netbeans)
mate ~/.subversion/config
Add an entry under the [tunnels] section like this:
ssh = $SVN_SSH ssh -l my_ssh_username
Save the file.
Now, Netbeans will be able to access your svn repository over ssh without needing a password from you.
6. Checkout from your repository
In Netbeans, If you go to the Versioning->Checkout dialog, you will see that the tunnel command is pre-populated for you. Just enter your repository location eg:
svn+ssh://myserver.net/repository
and everything should work fine.
Please also visit the Swirrl blog
Posted by Richard Roberts at Thursday, March 06, 2008 1 comments
Labels: IDE, Leopard, MySQL, NetBeans, OS X, Rails, Ruby, Subversion
Wednesday, 13 February 2008
The curse of the spreadsheet!
I recently wrote about the misuse of spreadsheets on the Swirrl blog.
Spreadsheets are great for some tasks. People love the informality, the flexibility and the instant results: in skilled hands, they can be very powerful. But “when all you have is a hammer, everything looks like a nail”... Read the full article.
Please also visit the Swirrl blog
Posted by Richard Roberts at Wednesday, February 13, 2008 0 comments
Labels: spreadsheets, swirrl
Wednesday, 6 February 2008
Swirrl on Rails
Just a quick announcement about the current rails project I'm working on:
It's called swirrl and you can read about it here.
Please also visit the Swirrl blog
Posted by Richard Roberts at Wednesday, February 06, 2008 0 comments
Labels: swirrl
Tuesday, 5 February 2008
Handling Errors in Ajax & Rails
A while ago, I was wondering how I should deal with errors that are encountered in rails controllers, while processing an Ajax request. I played around with some alternatives and eventually came up with one that has been working great for a few months, so I thought I'd share it.
You've probably all heard of overriding 'rescue_action_in_public' in your ApplicationController to deal with errors. (See simple example below).
def rescue_action_in_public(exception)
# render the error page.
render :file => "public/error.html"
end
This works great in regular methods, but what if something happens in an ajax request?
If you take no action, then the controller will fail 'silently' (well, some stuff appears in the log, but the user is unaware).
The way I got around this was to add a method to the ApplicationController, similar to that below (irrelevant code stripped out, so apologies if this code has a typo!).
def perform_ajax_action
if block_given?
begin
if (request.xhr?)
yield
else
raise RuntimeError.new('Not in an ajax request!')
end
rescue Exception => error
logger.error("#{Time.now}: Error performing ajax action: #{error.inspect}")
logger.error(error.backtrace.join("\n"))
ajax_aware_redirect_to "/error.html"
end
else
logger.error("perform_ajax_action called with no block!");
ajax_aware_redirect_to "/error.html"
end
end
(You were probably wondering what this 'ajax_aware_redirect_to' business is all about. It's just another method in the ApplicationController which helps with redirecting during ajax processing. It looks a bit like this: Again, irrelevant stuff removed.)
def ajax_aware_redirect_to(options = {}, *parameters_for_method_reference)
if request.xhr?
render :update do |page|
page.redirect_to( options, *parameters_for_method_reference)
end
else
redirect_to( options, *parameters_for_method_reference)
end
end
Now, in order to get this to catch your errors, you need to add an :around_filter to your controller. e.g.
class MyController < ApplicationController
around_filter :my_around_filter, :only => [:my_action]
# controller code here....
def my_around_filter
perform_ajax_action do
# do other useful stuff here if you like.
# in an 'around filter' yield calls the method wrapped in the filter
yield
end
end
end
Please also visit the Swirrl blog
Posted by Richard Roberts at Tuesday, February 05, 2008 2 comments