Code-Hero: Ruby
Managing Ruby with Code-Hero
👋 Welcome to the Stackhero documentation!
Stackhero offers Code-Hero, a complete development platform to code in seconds:
- Code from anywhere: Use any device, be it a desktop, phone, or tablet, without requiring any software installations.
- Integrated VSCode experience: Work with a customised version of VSCode directly through your browser, featuring a fully functional terminal.
- Comprehensive toolset: Benefit from a pre-configured environment with tools and languages like
Docker,Git,Zsh,Node.js,Go,Python,Ruby, and more.- Seamless connectivity: Access your development applications via HTTPS on a public domain, mimicking production conditions. This setup supports webhooks and external integrations effortlessly.
Experience the efficiency and convenience of Stackhero's Code-Hero development cloud solution. It takes just 5 minutes to get started! Simplify your development processes and save valuable time today.
Code-Hero simplifies the management of Ruby environments by using asdf, a versatile version management tool. This approach ensures your projects consistently use the correct Ruby version, reducing configuration mismatches.
By default, the latest Ruby version is pre-installed. To verify the active Ruby version on your system, you can run the following command:
ruby -v
Changing the default Ruby version
If your project requires a specific Ruby version, you can configure it by following these steps:
-
Update
asdfplugins:asdf plugin update --all -
List available Ruby versions:
asdf list all ruby -
Install the desired version:
asdf install ruby <VERSION> -
Set the active version:
-
Globally (sets the version for all directories):
asdf global ruby <VERSION> -
Locally (sets the version for the current directory only):
asdf local ruby <VERSION>This command creates a
.tool-versionsfile in your project directory to specify the Ruby version.
-
-
Verify the active Ruby version:
ruby -v
Starting a Ruby on Rails server
To make a Ruby on Rails server externally accessible, use the -b 0.0.0.0 option when starting the server:
bin/rails server -b 0.0.0.0
The server will then be accessible using the following URL:
http://<XXXXXX>.stackhero-network.com:3000
Resolving the "Blocked Host" error
If you encounter an error message like the following:
Blocked host: <XXXXXX>.stackhero-network.com
To allow requests to <XXXXXX>.stackhero-network.com make sure it is a valid hostname (containing only numbers, letters, dashes, and dots), then add the following to your environment configuration:
[...]
You can resolve this by editing the config/environments/development.rb file in your Rails project and adding the following line, replacing <XXXXXX>.stackhero-network.com with your actual server hostname:
config.hosts << "<XXXXXX>.stackhero-network.com"
For instance:
Hosts configuration example
By following these steps, you can effectively manage Ruby versions and ensure smooth operation of Ruby on Rails applications within the Code-Hero environment.