8 useful Rails Bytes to improve your development process
Abhinav Saxena
Posted on September 1, 2020
Rails Bytes is a platform created by Chris Oliver aka excid3 to share useful Ruby on Rails recipes/templates. These templates allow you to add features to both old and new apps. In the background, these templates may install a gem, run their installation steps, or edit configurations themselves. Of late, I have been using Rails Bytes for my new Rails apps, and here are a few of them (in no particular order) which I find very useful.
-
HAML: Add beautifully DRY, well-indented, clear markup.
I particularly enjoy writing clean markup, and I absolutely love HAML It also helps me understand the logic and intent clearly without getting lost in HTML. This template also lets you automatically convert your
.erb
files to.haml
files. You also get an option to retain your.erb
files in case you want to go back.
rails app:template LOCATION='https://railsbytes.com/script/x7msKK'
- Live Reload: LiveReload with Webpack for views and viewcomponents. I was recently exposed to Gatsby, and live reloading added so much to my productivity. Live Reload template tries to emulate the same for Rails. It used webpacker. There's another template on Rails Bytes which achieves the same using guard.
rails app:template LOCATION='https://railsbytes.com/script/V1bs61'
-
dotenv: A Ruby gem to load environment variables from
.env
. One of the tenets of a twelve-factor app is storing configuration in the environment. In the development environment, this template uses dotenv-rails gem which loads environment variables from .env file in the development environment.
rails app:template LOCATION='https://railsbytes.com/script/zOvsQ0'
- Simple form: Rails forms made easy. Rails default forms abstract native HTML forms well, Simple form takes this abstraction a little further and helps you create forms easily.
rails app:template LOCATION='https://railsbytes.com/script/VQLslK'
- Recreate: Rake task to drop schema and recreate the database. I am not sure if it's only me - but because of multiple reasons, I tend to recreate my development database numerous times. Rake task added by this template makes it very easy to do.
rails app:template LOCATION='https://railsbytes.com/script/VQLsoK'
- Annotate: Annotate Rails classes with schema and routes info. Rails does magic with ActiveRecord, and while I completely love it, I also need to refer to column names very frequently. This template and underlying gem help you achieve that.
rails app:template LOCATION='https://railsbytes.com/script/Vqqsqg'
-
Strong Versions: Ensure your gems are appropriately versioned.
I have seen production issues arising because of version mismatch of gems and other external libraries. Install strong_versions gem to enforce stricter policy on your
Gemfile
requirements.
rails app:template LOCATION='https://railsbytes.com/script/xjNsMn'
- High Voltage: Add High Voltage to manage static pages. There are static pages in every app, and High Voltage using a good convention saves you from building unnecessary controllers for static pages. For more details check out High Voltage gem.
rails app:template LOCATION='https://railsbytes.com/script/XbBsdZ'
(cross-post from my personal blog)
💖 💪 🙅 🚩
Abhinav Saxena
Posted on September 1, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.