Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Ruby on Rails 3.2 on Red Hat Enterprise Linux 6 with Software Collections

January 31, 2013
Bohuslav Kabrda
Related topics:
Linux
Related products:
Red Hat Enterprise Linux

Share:

    While Red Hat Enterprise Linux is known for its stability and flexibility, you might not think of it first when looking for the latest version of your web application framework. If you're a developer working with Ruby and Ruby on Rails, you probably want to take advantage of their new features. Sure, you can use RVM, but sometimes you just want to get supported system packages.

    Software Collections (often abbreviated as SCL) allows you to run more recent versions of software than what ships with your current version of Red Hat Enterprise Linux. This article will show you how to start development of a Rails 3.2 application running on Ruby 1.9.3 - all on RHEL 6, using only RPM packages, alongside your default Ruby installation. This tutorial assumes that you are familiar with Ruby on Rails basics, such as creating a new application and using bundler. It is also beneficial (although not necessary) to understand how Software Collections work in general.

    Installing the ruby193 Collection

    Throughout this tutorial, we will be using the ruby193 SCL. To get started, we will need to add it to Yum repositories. Grab a copy of the repofile and put it in /etc/yum.repos.d/

    Now you can install all the packages needed for creating a Rails 3.2 application just by running (with proper privileges, of course)

    yum install ruby193
    

    While this takes some time, you'll have all the packages that you need for this exercise.

    Kickstarting a New Application

    Now that the collection is installed, you can create a new Rails application. It is important to note that all Ruby-related commands must be run in the SCL enabled environment. Otherwise they will not work or may trigger unexpected behavior.

    You can run Ruby-related commands in the SCL enabled environment in two ways.

    1. Run every command in SCL enabled environment like this:

    scl enable ruby193 "ruby -v"

    2. Run a subshell (more convenient and comfortable) that will be SCL enabled itself:

    scl enable ruby193 "bash"

    In this subshell, you can run any command as you normally would without having to remember to use "scl enable" for every command. Don't forget to enable the SCL every time you run anything that needs Ruby (e.g. rspec, minitest, rails, ...).

    To create a new application called "app", you need to issue the command:

    rails new app

    This will create a standard Rails 3.2 application with one small change in the way that Bundler is run.

    Bundler Trouble

    Normally, when creating a new Rails application, the generator calls "bundle install", which results in installing the newest versions of all Gems; this would render the SCL packaged Gems useless, as most of them would be rendered obsolete by newer versions and not be used. If you are choosing the collection for development, you probably don't want that. The default generator has been altered to run "bundle install --local", which utilizes the newest local versions of Gems (the ones from the collection). If you don't like this setup, you can always delete app/Gemfile.lock and run "bundle install" in the app directory to get the newest versions.

    Generally, if you want to start using a new Gem that is part of the collection (run "yum list 'ruby193-*'" to see the complete list, not all are installed by default), you have to

    • install it with Yum ("yum install ruby193-rubygem-foo")
    • add it to Gemfile
    • run "bundle install --local".

    If you want to use a classic Gem from rubygems.org,  you only need to add it to Gemfile and run "bundle install".

    Running the Application

    Now that the application is created, you can try to run it. Use:

    cd app
    rails s
    

    You will get an error message containing this string:

    Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
    

    Why? Rails developers have made a decision not to assume what JavaScript engine you want to use. There are number of these: therubyracer, therubyrhino, NodeJS... The ruby193 collection contains therubyracer, so we will use it (it gets installed with the collection, so you don't need to install it separately). Open Gemfile in your favorite text editor and uncomment the line that reads:

    # gem 'therubyracer', :platforms => 'ruby'
    

    Next run "bundle install --local" again. Now try running the development server again:

    rails s

    Success! You can now go to http://0.0.0.0:3000/ to see the title page of your new Ruby on Rails 3.2 application on RHEL 6. Everything is set, so you can start coding just as you are used to.

    Last updated: November 2, 2023

    Recent Posts

    • Assessing AI for OpenShift operations: Advanced configurations

    • OpenShift Lightspeed: Assessing AI for OpenShift operations

    • OpenShift Data Foundation and HashiCorp Vault securing data

    • Axolotl meets LLM Compressor: Fast, sparse, open

    • What’s new for developers in Red Hat OpenShift 4.19

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue