Top Visual Studio Code (VScode) Extensions for Ruby on Rails

Visual Studio Code - VSCode Extensions for Rails

When working with Ruby on Rails, Visual Studio Code (VSCode) can be your go-to editor with the right extensions. Here, we’ll go over the most effective VSCode extensions for Ruby on Rails, designed to improve coding speed, reduce bugs, and help organize code. This guide will show you the best VSCode tools for Ruby on Rails, with a focus on productivity, functionality, and ease of use.

Why Use VSCode for Ruby on Rails?

Visual Studio Code is a versatile, lightweight editor favored by many developers. With a huge library of extensions, it can be customized for almost any tech stack, including Ruby on Rails. While VSCode doesn’t offer the built-in Ruby support of more traditional IDEs like RubyMine, it can become an efficient Rails editor with a few key plugins.

Essential VSCode Extensions for Ruby on Rails

Here’s a rundown of the top extensions to improve your Ruby on Rails coding experience.

1. Ruby (Peng Lv)

The Ruby extension by Peng Lv is a must-have for any Ruby developer. It offers essential features like syntax highlighting, formatting, and code linting. Additionally, this extension provides code navigation and method suggestions, making it easier to write and debug Ruby code.

  • Key Features:
  • Syntax highlighting and autocompletion
  • Error detection with built-in linting
  • Compatible with VSCode’s IntelliSense for Ruby

Tip: Pair this with the Ruby Solargraph extension (below) to enhance your Ruby language support.

2. Solargraph

Solargraph brings language server capabilities to VSCode, offering in-depth autocompletion, method suggestions, and code intelligence for Ruby. This extension is especially helpful if you work with complex Rails projects, as it can help track variables, classes, and methods across files.

  • Key Features:
  • Intelligent autocompletion and inline documentation
  • Code navigation for large codebases
  • Real-time linting and error checking

Setup: You’ll need to install the Solargraph gem in your project with the command gem install solargraph.

3. Rails (Grzegorz Witek)

The Rails extension by Grzegorz Witek is tailored for Rails developers. It enhances Rails projects in VSCode by offering specialized commands and shortcuts, such as navigating between models, views, and controllers with ease.

  • Key Features:
  • Command palette with Rails-specific shortcuts
  • File and folder generator commands for Rails components
  • Go to commands for faster navigation between models, controllers, and views

Use Case: Perfect for Rails developers who need to streamline file generation and navigation within their projects.

4. ERB Helper

The ERB (Embedded Ruby) Helper extension is designed to make working with .erb files easier. It includes syntax highlighting and code formatting for ERB templates, improving readability for embedded Ruby code within HTML files.

  • Key Features:
  • Syntax highlighting for .erb files
  • Autocompletion for HTML and Ruby code within templates
  • Inline comments and documentation support

Why It Matters: This extension is essential for those who frequently work with Rails views, as it enhances the development experience with embedded Ruby code.

5. Bracket Pair Colorizer

Bracket Pair Colorizer is a simple yet effective extension for highlighting matching brackets. It color-codes opening and closing brackets, making it easy to follow complex code structures in Ruby and Rails.

  • Key Features:
  • Unique colors for different bracket pairs
  • Customizable colors and bracket options

Best For: Ideal for developers working with deeply nested code, like Rails views and controllers.

6. GitLens

GitLens is one of the most popular Git extensions for VSCode. It offers a range of features like inline Git blame, file history, and code authorship tracking. This is invaluable for teams or solo developers who want to track changes within their Rails projects.

  • Key Features:
  • Inline Git blame and author information
  • Seamless integration with GitHub, GitLab, and Bitbucket
  • Code lens for visualizing Git history within your project

Why It’s Great: If you work with Git often, GitLens helps keep track of code changes and ownership.

7. VSCode Ruby Test Explorer

Ruby Test Explorer is a VSCode extension specifically for running tests in Ruby. With Test Explorer, you can view test results and navigate through test files easily, making it an essential tool for Test-Driven Development (TDD) in Rails.

  • Key Features:
  • Run tests and view results within the VSCode interface
  • Visual display of test passes and failures
  • Supports RSpec, Minitest, and other testing frameworks

Tip: Test Explorer also integrates with coverage tools to highlight tested code.

8. Path Intellisense

Path Intellisense is a simple extension that provides file path suggestions as you type. In a Rails project with multiple folders and files, this can save time when you need to import files, especially in views and assets.

  • Key Features:
  • File path autocompletion
  • Faster navigation through the file system

Why You’ll Love It: It helps reduce time spent searching for file paths, which is especially useful in larger Rails projects.

9. Rails DB Schema

Rails DB Schema is a handy tool that generates a visual schema of your Rails database, showing tables, relationships, and associations. This extension is especially helpful for managing database structure and understanding how your models interact.

  • Key Features:
  • Graphical view of the database schema
  • Table and relationship visualization
  • Compatible with PostgreSQL, MySQL, and SQLite

How to Use It: This is great for anyone working on database-heavy applications, making schema management more intuitive.

10. Rubocop

Rubocop is a Ruby code linter that helps enforce style guidelines and catch errors. While it’s not exclusive to Rails, it’s incredibly useful for ensuring clean and consistent Ruby code.

  • Key Features:
  • Enforces Ruby style guide and best practices
  • Customizable rules and formatting options
  • Works in tandem with Rails-specific rulesets

Pro Tip: Set up a .rubocop.yml file to customize the rules according to your project’s needs.

Additional Tips for Enhancing VSCode with Ruby on Rails

Here are a few extra ways to customize your VSCode setup for Ruby on Rails:

  • Set Up Custom Keybindings: You can create custom keybindings in VSCode for Rails commands or tasks you perform often. This can improve your workflow and help you work faster.
  • Use Themes Optimized for Ruby: Some themes are more Ruby-friendly, offering colors and highlights that enhance Ruby and Rails code. Popular options include Monokai Pro and One Dark Pro.
  • Utilize Built-in VSCode Shortcuts: Learn VSCode shortcuts for file switching, command palette, and sidebar toggling to increase coding speed.

Benefits of Using VSCode with Ruby on Rails Extensions

Using the right extensions can speed up your development process, reduce errors, and make your workflow more efficient. Extensions like Solargraph and Rails integrate advanced features, while simpler tools like Bracket Pair Colorizer and Path Intellisense add small but effective boosts to your coding experience.

In Summary:

  • Choose extensions based on your specific needs, whether it’s code navigation, debugging, or syntax highlighting.
  • Combine multiple extensions for the best experience.
  • Customize your setup with themes and keybindings.

By taking the time to configure your VSCode environment with these Ruby on Rails extensions, you can streamline your workflow and get the most out of your coding sessions. Whether you’re a new Rails developer or a seasoned pro, these extensions help make Rails development in VSCode an efficient and enjoyable process.

Scroll to Top