IDEs

An Integrated Development Environment (IDE) is an essential software tool that makes the process of development and packaging process a lot easier, convenient and efficient. An IDE provides a one-stop solution for editing the code, compiling and debugging it, and running the application. IDEs also have features such as syntax highlighting, document generation, and version control etc.

Several IDEs are available for Rails. This chapter introduces some of the widely used IDEs for Ruby on Rails.

RubyMine

Developed by JetBrains, RubyMine is one of the most popular IDEs amongst the Rails developers. Code completion, powerful refactoring and debugging and integration with Git are some of its important features. RubyMine also supports various web technologies, such as HTML, CSS, and JavaScript, thus making it a great choice for web development.

RubyMine is a proprietary software, however it comes with a 30-day trial version. It is available for use on Windows, macOS as well as Linux. It can be downloaded from https://www.jetbrains.com/ruby/download/.

For Ubuntu Linux, you can install RubyMine with the following command −

sudo snap install rubymine classic

To install on Windows, download the latest installer (RubyMine-2024.3.2.1.exe) and run the installation wizard, keeping most of the default settings.

After the installation is complete, launch RubyMine and start a new Rails project.

RubyMine

Under the Rails tab, select application, specify the Ruby interpreter, Rails version and the project folder path.

RubyMine 1

Click on the Create button. RubyMine creates the folder structure of a Rails project. Open the terminal (View > Tool Windows > Terminal) and start the Puma server with the command −

~\RubymineProjects\NewRailsProject> rails server

You can now visit http://localhost:3000 to get the welcome page displayed.

VS Code

Visual Studio code is one of the most popular IDEs as it supports multiple languages through its extensions library. You can customize the VS Code installation by loading certain Ruby and Rails-specific extensions.

After launching the VS Code application, search and install the following extensions −

Ruby LSP

The Ruby LSP is an implementation of the language server protocol for Ruby, used to improve rich features in editors.

Ruby LSP

Rails

This extension provides Ruby on Rails support for Visual Studio Code.

Ruby Visual Studio Code

Ruby Solargraph

Solargraph is a language server that provides intellisense, code completion, and inline documentation for Ruby.

Ruby Solargraph

ERB Formatter

This extension provides formatting for .erb files (embedded Ruby templates).

ERB files

After installing these extensions, you need to modify the GemFile in your application to install the corresponding gems.

group :developmentdo# Use console on exceptions pages [https://github.com/rails/web-console]
  gem "web-console"
  gem "ruby-lsp"# For Ruby LSP in VS Code
  gem "solargraph"# For code intelligence and autocompletionend

Then run the command −

bundle install

Restart VS Code and create a new Rails project.

Other Popular IDEs and Code Editors

In addition to RubyMine and VS Code, the following IDEs/code editors are also used for Rails development:

Atom by GitHub is an open-source text editor. Atom can be customized for Ruby on Rails development environment with the installation of the Atom Ruby IDE package and other relevant plugins.

Sublime Text is a lightweight text editor. With the addition of packages like Sublime Text 3 Ruby on Rails, it can work as a proficient Ruby on Rails IDE.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *