Add Ruby version to Gemfile

Since Bundler 2.4.19, including in Ruby 3.2.3, it's possible to define
the Ruby version in the Gemfile by indicating which file contains the
version [1].

There are at least two practical cases where this is an advantage.

First, people using RVM in development will no longer accidentally run
the application using the wrong Ruby version (which, before these
changes, might happen if they switch to a branch using a different Ruby
version and forget to run `rvm use` or exit the current folder and enter
it again) because they will get an error when trying to do so.

Second, people using services like Heroku no longer need to modify the
Gemfile.

The disadvantage is that, now, every time we update the Ruby version, we
have to remember to run `bundle` so our `Gemfile.lock` gets the new
version.

[1] https://github.com/rubygems/rubygems/releases/tag/bundler-v2.4.19
This commit is contained in:
Javi Martín
2024-12-09 15:23:40 +01:00
parent 7204b8bbec
commit cf6d9ce753
5 changed files with 8 additions and 26 deletions

View File

@@ -58,7 +58,7 @@ Este tutorial asume que ya has conseguido clonar Consul Democracy en tu máquina
**¡Recuerda no añadir el archivo si tienes información sensible en él!**
6. Para que Heroku detecte y utilice correctamente las versiones de node.js y ruby definidas en el proyecto deberemos añadir los siguientes cambios:
6. Para que Heroku detecte y utilice correctamente la versión de node.js definida en el proyecto deberemos añadir los siguientes cambios:
En el _package.json_ añadir la versión de node.js:
@@ -74,18 +74,6 @@ Este tutorial asume que ya has conseguido clonar Consul Democracy en tu máquina
heroku buildpacks:add heroku/nodejs
```
En el _Gemfile_ añadir la versión de ruby y ejecutar bundle:
```Gemfile
ruby file: ".ruby-version"
```
y aplicar:
```bash
heroku buildpacks:set heroku/ruby
```
7. Ahora ya puedes subir tu aplicación utilizando:
```bash