Rails 4 Support for RailsThemes Themes

Like most Rails developers, we waited with anticipation throughout 2013 for the Rails 4 release. Would it be released at Railsconf? Or maybe they would wait all the way until DHH’s birthday!?

Fortunately the Rails core team did not wait until October. Rails 4 was officially released at the end of June, and offers new features, improved performance, and bug fixes. Rails 4 only supports Ruby 1.9.3+, with Ruby 2 recommended.

How We Upgraded

Rails 4 is slightly different from Rails 3, so here are a list of the changes we needed to make so you can install RailsThemes themes into your Rails 4 app. A complete list of the changes between versions that are helpful to consider are listed at the Ruby guide for upgrading Rails.

Foundation / Compass Changes

All RailsThemes themes use Foundation 4, which relies on the Compass gem. Unfortunately, Compass had a blocking bug at the time of the Rails 4 release. Fortunately for us, Scott Davis and Marcus Ilgner fixed the issue. From here it was a matter of checking in the installer if a customer was trying to install into a Rails 4 app and using the custom branch listed in the Compass issue if that is the case.

Routing changes for sample pages

RailsThemes installs some sample views into your application so you can see how it works and have some local code samples to play around with. We generate some routes to let you see these pages.

Rails changed the way that routing works. Now you need to specify a route type (GET, POST, etc.). We changed our routes generation from lines like:

match '/' => 'railsthemes#index'


match '/' => 'railsthemes#index', :via => [:get]

Asset Gems No More

Previously gems that handled assets were put into a Bundler group named :assets. Rails 4 wants those gems at the top level grouping instead, so we changed the installer to check for Rails 4 and change how the Gemfile specifies asset gems that are needed.

And that is it!

Those were the only changes needed to upgrade our installer and asset pipeline to Rails 4. I was fairly surprised at how easy it was. I think this speaks to the stability of the Rails asset pipeline and the robustness of the RailsThemes theme delivery system.

I always get excited about new versions of Rails because it’s a great time to start a project that I have been thinking about starting. What new Rails projects are you thinking about working on now that Rails 4 has landed?

No comments yet.

Leave a Reply