Plasticx Blog

Capable of being shaped or formed

git workflow using remote repositories to maintain my version of Rails Typo blog

Posted by Mike 08/23/2011 at 12:48PM

This blog is using Rails based Typo ( as its framework. The Typo project is very active and just went through a major release and upgrade to Rails 3. I maintain the source code for the blog in a private repository; when I upgrade the latest Typo changes into my version, I do so using fdv's repository as a remote source repository. I then merge in the external changes, refine my configuration if needed, and redeploy the blog.

Here is the workflow that I use for these purposes. Starting from the absolute beginning would be to clone the repository, or ensure my master was checked out and its latest changes are pulled in.

# get a pristine copy of my own source, after cloning
# I will be at the HEAD of the master branch
git clone git://private/plasticx.git

# OR

# checkout master and ensure we are at the HEAD of
# master's history of our own source
git checkout master
git pull

Next, I make a remote branch of my repository to isolate my work within it. If for some reason my upgrade has complications while merging that are beyond my expertise I can simply throw that branch away and try again.

# create a remote branch called rails3
git push origin origin:refs/heads/rails3

# track and check out the rails three branch locally
git checkout --track -b  rails3 origin/rails3

The next step is to add fdv's repository as a remote repository and fetch its objects and references. We then merge in fdv's work using one of the release tags he has cut rather promiscuously pulling in the HEAD of his master branch.

# add fdv's typo as a remote repository
git remote add fdv

# fetch fdv's commits and merge in his 6.0.8 release
git fetch fdv
git merge release_6_0_8

At this point there was a number of merge conflicts to be dealt with. For instance, I had to update the local gem environment installing the gems specified by the project's new Bundler Gemfile. I resolved these issues and then set the branch in my Capistrano's deploy.rb to use the "rails3" branch I created to isolate the work I'm doing for this upgrade.

# if using Capistrano for deployment, we can set the
# branch we are deploying by setting the branch cap
# will check out for deployment in config/deploy.rb
set :branch, 'rails3'

I like to look at the diff of changes I'm about to commit so I use the -v flag when git is invoked to do so; the diff will be displayed below the commit message prompt in my editor.

# fix merge conflicts, change Capistrano branch, etc.
git commit -a -v
git push
cap deploy

I didn't get a perfect deployment the first time I did this. I had to do a number of iterations getting my blog's configuration set correctly for the shared hosting environment where its hosted at. One of the extra configuration items I had to add was to set the shell PATH for the environment Capistrano runs in on the server. This enabled me to use gems that I had installed locally since I didn't have control of the system gems in that environment. I also set the rake command that Capistrano uses to be invoked via Bundler's exec command.

set :default_environment, {
  'PATH' => "/home/mikemondragon/.gems/bin:$PATH"
set :rake, "RAILS_ENV=#{rails_env} bundle exec rake"

Happy Blogging!

Posted in , |

Migrating Legacy Typo 4.0.3 to Typo 5.3.X

Posted by Mike 09/07/2009 at 12:26AM

I completed the process of migrating this blog from Typo 4.0.3 to Typo 5.3.X. These are my notes on the process I undertook to complete the migration. I had self hosted the blog on a Linode slice and part of the migration was to switch the hosting to Dreamhost . I want to retain control of the Rails stack for the blog, but I no longer wanted to maintain the server and base application stack.

Source code

The source for the blog is actually from Frédéric de Villamil’s 5.3.X master Typo branch" at Github and if this isn’t necessary for your blog, you can skip past the git notes and install and maintain the source code in another prescribed manner.

Below are the steps to initialize a new git repository. Add in fdv’s master Typo branch as a remote repository. And finally, merge in fdv’s master branch. You would do so if you planned to frequently pull in the master changes to Typo as its being developed by the community, or if you had another remote branch you wanted to pull in changes from. Remember, at this point we are working locally.

mkdir mynewblog
cd mynewblog
git init
touch README
git add .
git commit -a -m 'start of my typo blog'
git remote add -f fdv git://
git checkout -b fdv/master
git pull fdv master
git checkout master
git merge fdv/master

Also, you’ll want to install the gems that Typo relies upon, and freeze in Rails 2.3.3

sudo rake gems:install
rake rails:freeze:edge RELEASE=2.3.3
git add vendor/rails
git commit -m 'freezing in Rails 2.3.3' vendor/rails

Finally, move the git repository you’ve just initialized to your preferred place to host your projects. Perhaps a private Github repository. I host some of my personal projects on a remote server and just pull from it over ssh.

Migating data

I dumped the production data from my old Typo 4.0.3 blog such that I could migrate it in my local environment.

mysqldump -u root --opt my_old_typo_db > /tmp/old.sql

I then scp’d the old data locally and imported it into a new database that was used for the local migration to Typo 5.3.X.

mysqladmin -u root create typo_development
scp mike@olderserver:/tmp/old.sql /tmp/
mysql -u create typo_development < ~/tmp/old.sql
cp config/database.yml.example config/database.yml
# edit database.yml with local settings
rake db:migrate

One small gotcha for me was that I was using the “recent comments” sidebar from Typo 4.0.3 and I had to manually remove it from the stored settings in the database via the mysql prompt. Use Rails dbconsole script to bring up a mysql console.

ruby script/dbconsole

Now delete the recent comments configuration.

delete from sidebars where type='RecentCommentsSidebar';

All of the data should be migrated correctly from 4.0.3 to 5.3.X at this point. Post a comment if you’ve encountered an issue doing your own migration.



Pink is punk, and I upgraded the Pink Theme to be Typo 5.3.X compatible. The Pink Theme had been orphaned after 4.0.3 so I had to make some code changes so it would operate in a Typo 5.3.X environment. This is the github project page for Pink

I then added Pink as a git submodule so its code would remain independent of my project, yet still be available when the app was deployed.

git submodule add themes/pink
git submodule update

See the Capistano notes below for additional information about git submodules and Capistrano


I’ve had good success with the Hoptoad exception notifier so I added it to my project as well.

ruby script/plugin install git://
# edit your config/initializers/hoptoad.rb settings
git add vendor/plugins/hoptoad_notifier/ config/initializers/hoptoad.rb
git commit -m 'adding hoptoad notifier and its initializer' vendor/plugins/hoptoad_notifier/ config/initializers/hoptoad.rb

I’m not sure if others are deploying plugins as submodules, but I prefer to freeze plugins into my Rails app.


I used the Deploying Rails On Dreamhost with Passenger Rails Tips article and Github’s Deploying with Capistrano article to guide my Capistrano setup. After doing a "capify ." to initialize Capistrano in the project, I added a couple of extra settings and tasks to config/deploy.rb that make the setup specifically tailored for Typo’s configuration on Dreamhost.

First, make Capistrano fetch all the submodules your project is dependent upon during deployment in config/deploy.rb

set :git_enable_submodules, 1

The tasks below are also required. The first is the common touch of the tmp/restart.txt file in the current directory that signals Passenger to reload the application. The second task does three things. It links database.yml from the shared directory to the current directory. The second links the shared files directory into the current directory. The public/files directory is where Typo saves any files that are saved as a part of its minimal content management system. Use this strategy so that the files themselves are not dependent upon deployment or stored in your source code repository. Last is something specific to my blog. I use Get Clicky to track visitors statistics. My blog is currently using the Pink theme and I didn’t want to make Pink dependent on my Get Clicky configuration. Therefore I just copy over a modified Pink layout with my Get Clicky settings whenever a new version of the site is deployed.

namespace :deploy do
  task :restart do
    run "touch #{current_path}/tmp/restart.txt" 

desc "link in shared database.yml, etc. with symbolic links"
task :link_in_shared_files do
  run "ln -s #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  run "ln -s #{shared_path}/public/files #{release_path}/public/files"
  run "cp -f #{shared_path}/themes/pink/layouts/default.html.erb #{release_path}/themes/pink/layouts/"

after "deploy:update_code", "link_in_shared_files"

Notice that I made the link_in_shared_files task dependent to run after the the Capistrano standard deploy:update_code task has fired.


In the virtual host settings for my blog’s old location I promiscuously redirect each request exactly to the new location.

# redirect old apache server:
RedirectMatch permanent  ^(.*)$$1

These redirects are 301 permanent redirects so that Google and the other search engines will update their indexes permanently to the domain it now resides upon.


The End

So far I’m happy with this setup. For me, its easy to deploy and maintain. Please post any experiences you’ve had with Typo migrations or Typo hosting so that others might benefit from your experience as well.

Posted in , , , |

Last blog post of 2007?

Posted by Mike 12/11/2007 at 02:10PM


I’ve been in a writers block for useful bits of information to post on my blog. I guess I’ll give a summary of things I’ve seen and done lately and perhaps that will inspire others.


I started my own S-Corp. to work freelance out of over the summer. I was motivated to do so after attending the The Business of Rails session at RubyConf 2007. And I’ve gotten a lot of great tips on how to be a business person in Rails from the Google group Ruby on Rails meets the business world

I started consulting through Contentfree over the summer. They are a Rails consulting shop and have been working on a startup for their Eachday photo and memories sharing site. Its been great to working with Dave Myron there. Dave is one of the best coders and software designers I’ve ever worked with and I’m not saying that just to get more work!


I went to RubyConf 2007. It was fun. I played a lot of Werewolf (see #53) in the evenings. Sadly, it felt like the close knit party was/is over in the Ruby community since all the momentum that Rails has brought to Ruby is bringing in the masses (I’m in that group, one of “those guys”). My guess is that RailsConf 2008 is going to feel like a JavaOne, and RubyConf 2008 will feel like RailsConf 2007 with to many tracks.


At RubyConf I got to meet the people I’ve met in the #fauna channel on I think some of the greatest Ruby code and ideas I’ve been exposed to are from people in that channel. Shout outs to adamblock, agile, evn, lifo, heaveysixer, loincloth, defunkt, and others.

Evan Weaver

Evan is a genius and pretty cool dude.


Pratik is a genius and is very active on RailsCore contributions. He says Just Say No To Named Spaced Models so I guess you should ignore this post: Rails Models in a Namespace

Chris Wanstrath

Chris is a genius is full of ambition Ambition Google Group

ditching Typo

I’m probably going to ditch this Typo blog when I can make time to do it. I’ll either go with an another Rails based blog called Mephisto or Evan Weaver’s Bax blog which uses scripts and Apache SSI and is hidden on fauna’s SVN on Ruby Forge: ‘svn co svn://’

like Ozimodo

I’ve been thinking about doing a Camping based tumblelog. I even paid a designer to make a template for it. I’ll blog about that latter. It will be like Ozimodo and probably steel code from it.


I’m sitting on a Gem called imPOSTor that will post comments to forums such as phpBB and Web Wiz Forums . I’ll probably release within the month. It has been working inside a production grade private Rails app for over a month so I think its ready to be released. “The imPOSTor library is used to automate the act of posting comments and data to forums such as phpBB and WWF. impostor encapsulates the work of posting to these forums using a common (ruby) interface.”


I’m about to finish the next major version of MMS2R (2.0) . I think I’ve found the best architecture for it be maintained for the long haul. Each release of MMS2R is named after a character in the Metalocalypse cartoon.

Speaking of MMS2R Luke Francl and I submitted a MMS + Rails proposal for RubyConf 2008 called “Mobile Messaging with Rails”. Luke and I are also writing a PeepCode book about Rails+MMS+Mobile phones.

Posted in , , , , , , , |

Maintaining Your Own Typo 4.0.3

Posted by Mike 04/08/2007 at 05:12PM

This is the combined experience from my previous entry Typo 4.0 + Apache2 + MySQL + Gentoo and Chapter 27 Deployment and Production / Agile Web Development with Rails and Capistrano: Automating Application Deployment

What I am illustrating here is how to maintain a Typo blog. What I mean by maintain is that you are creating your own
source repository for your instance of Typo. This will allow you to patch the application with fixes and your own
modifications. You will also integrate Capistrano into your repository so that you deploy your updates with ease.
Also, I show you my implementation of a Mongrel init.d script on Gentoo that will ensure Mongrel starts back up on
server reboot.

Posted in , , , , |

WP-Notable In a Typo 4.0 Theme

Posted by Mike 10/25/2006 at 11:10PM

Here are some quick notes on getting WP-Notable style book marking into the Scribbish Typo 4.0 Theme. This pattern would apply to other themes as well.

Posted in , |

Typo 4.0 + Apache2 + MySQL + Gentoo

Posted by Mike 10/24/2006 at 12:13AM


This article deprecated by my Maintaining Your Own Typo 4.0.3 article.

The section in this article about the apache proxy is flawed, it doesn’t actually balance the load. There is also a better way to craft an init.d script generically for Mongrel in my new article.

I’ll leave the article in place for reference only.


I’ve almost completed my Typo 4.0 + Apache2 + MySQL + Gentoo configuration. Some system administration is Gentoo flavored but I think this is a good rececipe for anyone looking to do setup of Typo 4.0 within an Apache2 instance with MySQL for the datasource.

Posted in , , |

Test Driven Development In Rails (TDD)

Posted by Mike 10/17/2006 at 11:38PM

I was talking to Geoffrey Grosenbach (of nuby on rails fame) at Seattle.rb tonight mostly about Typo and his new Peep Code screen casts. Somehow he told us that his next Peep Code screen cast was going to be on TDD. That was my opening to complain about actually writing the test first. To be frank, I put my foot in my mouth, and unit testing in Rails has changed the way I code and in turn has made me a better programmer.

Posted in , , , |

Web Statistics