Why not use some kind of placeholder + replacement like we did on:

https://github.com/Helabs/pah/blob/master/lib/pah/partials/_ruby_env.rb

This way we don't need to keep track how many spaces we need on the Gemfile, we just replace the RAILS_VERSION