Rails And Merb Merge

On to the news: beginning today, the Merb team will be working with the Rails core team on a joint project. The plan is to merge in the things that made Merb different. This will make it possible to use Rails 3 for the same sorts of use-cases that were compelling for Merb users. Effectively, Merb 2 is Rails 3.

Katz Got Your Tongue? » Rails and Merb Merge

Great news!

How to use git plugins in your subversion rails project

If you like me still use subversion for your own rails projects but you want to use all the latest and coolest rails plugins that are hosted in a git repository you need to do as follows.

Start with installing git. If you use OS X you can download an installer here.

After you’ve done that use the following line to clone the remote git repository in your local vendor/plugins directory.

git clone --depth 1 git://github.com/fauna/has_many_polymorphs.git vendor/plugins/has_many_polymorphs

Change the address to the git repository and the name of the directory under vendor/plugins to fit your needs. In the above example I got the has_many_polymorphs plugin from github.

The checked out directory can then be added to your subversion repository like all other files. If you later want to update the plugin all you have to do is enter the directory and execute.

git pull

This ‘Using Git like svn:externals’ article helped me figure this out.

How to copy production database data to the development database with Capistrano

At times it is useful to easily be able to copy the content of the production database to the database running on your local development machine. In my case I use mysql on the production server and sqlite on my MacBook Pro. Unfortunately the use of different database servers makes this task a bit more tricky.

With a bit of googling I found a bit of code here and there which I combined and modified and turned into the following snippet of code to be dropped into your Capistrano deploy.rb file.

desc "Copy production database to development database"
task :update_dev_db, :roles => :db do
db = YAML::load(ERB.new(IO.read(File.join(File.dirname(FILE), 'database.yml'))).result)['production']

filename = “#{db[‘database’]}_dump.#{Time.now.strftime ‘%Y%m%dT%:%H%M%S’}.sql”
remote_path = “#{current_path}/tmp/#{filename}”
local_path = “tmp/#{filename}”

on_rollback { run “rm #{remote_path}” }

run “mysqldump -u #{db[‘username’]} –password=#{db[‘password’]} –skip-opt #{db[‘database’]} –complete-insert=true –skip-quote-names –no-create-info > #{remote_path}” do |ch, stream, data|
puts data

get remote_path, local_path

converted = File.read(local_path).gsub(/\’/, ‘\’\”)
File.open(“#{local_path}_converted”, ‘w’) {|f| f.write(converted)}

system “sqlite3 db/dev.db < #{local_path}_converted”
system “rm #{local_path}”
system “rm #{local_path}_converted”
run “rm #{remote_path}”

There is a small problem with \n (new line) characters that on the production server get evaluated as they should. However, on the development machine after the data has been exported from mysql and imported into the sqlite database the \n characters will show as \n on the screen. But for me this is good enough for now.

Back to Apache

I’ve used nginx with php through fastcgi for the php sites and with a mongrel cluster for each rails application on this machine for quite some time now and I’ve been happy with that setup.

However, with the number of rails applications increasing, the number of mongrel instances running increases even faster as each application needs between 2 and 5 mongrel instances.

I see Phusion Passenger (a.k.a mod_rails for Apache) as a way to simplify my setup. Passenger is supposed to do the same magic with Apache for rails as mod_php does for php.

The first step towards this dream setup was to change back from nginx to apache2. As I’ve had to have apache running behind ssl for the subversion repository changing back just meant figuring out how to configure apache to proxy for the mongrel clusters but a bit of googling solved that pretty quickly.

So right now this site is yet again powered by Apache but I’m still running mongrels to serve the rails applications. The next step is to move over to passenger, which I hope to do before the weekend.

I’ll let you know how it goes.


Me preparing to rappel down

As I mentioned earlier we spent Saturday at Hultberget outside of Eskilstuna. After lots of trips this spring to Fjärdhundra and Gåseborg we felt we needed to try something new. Camilla had been to Hultberget three years ago and liked it, even though the climbing then had been a bit too hard for her.

It was with great expectations we set off early Saturday morning, however, it wasn’t long after our arrival the humiliation started. I had difficulties with the 6a+ route we chose to warm-up with. I had to hang serveral times and generally had huge problems finding holds and figuring out body movements. That’s quite unusual.

I did make up for it a bit on the second climb for the day when I lead the same route again but doing the direct start that was graded 6b. It still felt quite hard though.

We continued with “En kvinnlig list”, a 6c route that we were recommended, where I got totally humiliated in the start. After pulling on some gear I did get past the first problem only to get stuck on the middle section where you are traversing to the right on quite poor holds for the hands, nothing for the feet and you have to stop and clip in the middle. I did manage that section in the end but it was after quite much hard work and cursing!

After Camilla cruised the route on toprope! I had to try to lead it again. I figured out the beginning of the route after I got a hint to use a gaston for the left hand which helped a lot. So I rather easily got up to the middle section where the holds for the feet go away completely. I smear my right foot, manage to release my right hand and reach up and clip the rope, only to feel my energy drain by the second and a coward as I am I scream “Take!” to Camilla and I’m left hanging in the rope pondering another failure.

The rest of the day continued in the same fashion. I read the guide book wrong and tried to onsight a 6c route instead of a 6b+ route. That didn’t go too well! When I finally found the 6b+ route it turned out to be hard as hell and I had to give up and go around the crag and set up a top-rope. Quite a failure!

But it was a nice day with lovely Swedish spring weather, and I think our failures were mostly due to us not being that familiar with the crag and the type of climbing it requires. Hopefully we make up for it the next time we return.