Andy from Webcrunch

Subscribe for email updates:

Portrait of Andy Leverenz
Andy Leverenz

January 5, 2020

Last updated November 5, 2023

A Tour of the High Voltage Gem - Ruby on Rails

The High Voltage gem is one of my favorite no-nonsense Ruby gems that gets you moving quickly when the need for static pages arise in your Rails app.

I recently published a list of some of my favorite Ruby gems but forgot to include this one. Doh!

Nearly any Ruby on Rails application I've built has needed some form of generic page. Doing this is very possible with a basic controller, views, and routing but the High Voltage gem is even easier. Simply add the gem to your Gemfile, run bundle install, create some templates within app/views/pages and you're off to the races.

The best part is that there are no routing patterns to remember or much configuration at all. By default the URL structure of the High Voltage gem uses /pages/your-page-name. While that works perfectly I often reach for a configuration that rids of the /pages URL structure. To do that you can add an initializer to your app with the following:

# config/initializers/high_voltage.rb

HighVoltage.configure do |config|
  config.route_drawer = HighVoltage::RouteDrawers::Root

And with that setting, you can turn /pages/about into /about.

Making static pages is a breeze with this gem. There is even documentation available explaining how to customize it even further as well as keep an up to date sitemap for more enhanced SEO. I invite you to take it for a test drive and see what you think!

Link this article
Est. reading time: 1 minutes
Stats: 2,026 views



Part of the Ruby on Rails collection