Blog

High Voltage: Use rails to create static pages

Icône flèche bleue vers la gauche
Back to blog
High Voltage: Use rails to create static pages

High Voltage: Use rails to create static pages

September 23, 2012

You certainly have frequent inclusion of one or even more static pages in your projects ! In order to succeed in this task, you have several choices: either code it into pure html (meaning include the entire layout of your pages which require a lot of boring work) or even worst, you could create a resource and all the linked views.

A better solution but quite time consuming is to implement a page controller which could handle all your static pages ( a bit like a cms) but this involve often a backend and a lot of other fancy things that you sometimes don’t need at all because these static pages are not going to change on a day to day basis and certainly because you’re a programmer and not a journalist !

Hopefully, a new solution comes out of the woods ! The high voltage gem ! This allow you to create easilly static pages in your Rails application.

Just include the gem in your Gemfile: gem "high_voltage".

Write your static pages and put them in the RAILS_ROOT/app/views/pages directory.

For instance: app/views/pages/about.html.erb

and finally call it elsewhere: link_to "About", page_path("about")

You’re done !

By the way using this gem allow you to keep all the ruby on rails magic stuffs you like and that are often so helpfull !

Here is usefull links if you need more information:

Ready to build your software product? Contact us!