5 Essential Visual Studio Plugins for Ruby on Rails Developers

Ruby on Rails is one of the most popular web development frameworks, powering over 1 million websites worldwide including Airbnb, Shopify, and GitHub. Rails helps developers rapidly build scalable applications by emphasizing convention over configuration and providing a rich ecosystem of tools and libraries.

However, even with all of Rails‘ built-in capabilities, having a productive development environment is still crucial. A good IDE can help you navigate large codebases, spot errors before they become bugs, and ultimately write better code faster.

That‘s where Visual Studio comes in. While perhaps best known for its C# and .NET support, Visual Studio is actually a powerful multi-language IDE. Thanks to its rich extensibility model, there‘s a vast marketplace of free plugins that customize it for different stacks, including Ruby on Rails.

In this in-depth guide, I‘ll showcase 5 essential Visual Studio plugins for Rails developers. These tools have saved me countless hours of development time over the years and helped me ship better apps. I‘ll explain what makes each plugin uniquely helpful and share some real-world usage examples.

By the end of this article, you‘ll have a ready-made VS plugin pack that will supercharge your Rails workflow. Let‘s dive in!

1. Ruby – The Ultimate Language Support

At the foundation of any good Rails development setup is solid Ruby language support. After all, Rails is built in Ruby, so you‘ll be writing pure Ruby code for models, controllers, helpers, etc.

The aptly-named "Ruby" VS extension is the most downloaded Ruby plugin, with over 1.3 million installs. Maintained by Microsoft with contributions from the community, it brings VS Code‘s renowned editing and debugging experience to Ruby.

Some key features include:

  • Code completion and IntelliSense powered by Solargraph
  • Automatic Ruby environment detection with support for all major version managers
  • Lint support via RuboCop, Standard, and others to catch code smells early
  • Code formatting powered by Rubocop or Prettier for consistent style
  • Interactive debugging with breakpoints, variable inspection, and other common debugging tools

Here‘s a peek at that powerful IntelliSense to auto-suggest Rails view helpers as you type:

Ruby extension intellisense demo

I can‘t overstate how helpful good code completion is for learning and using Rails APIs efficiently. With this plugin I rarely need to pause to look up docs.

It also integrates with other plugins like Solargraph to supercharge completion and enable advanced refactoring. More on Solargraph later.

The debugging support is also excellent and pretty much on par with RubyMine in my experience. You can easily set breakpoints, step through code, inspect variables, and execute arbitrary expressions in the debug console.

Whether you‘re new to Ruby or a veteran, this extension is a must-have for productive editing. It‘s the foundation all the other plugins build on.

2. Rails – Navigate Your App Like a Pro

Building on top of the Ruby extension, the "Rails" plugin from the prolific Bung87 adds specific support for Rails conventions and APIs. While Ruby provides general language features, Rails adds many framework-specific idioms and abstractions that benefit from their own tooling.

Some of the key features this extension offers:

  • Syntax highlighting for ERB/EJS templates and other Rails-specific files
  • Code snippets for quickly generating common Rails views and partials
  • Go to Definition navigation between models, views, controllers, and other related files
  • View path auto-suggestions and model attribute completion based on schema
  • Integration with RDOC and YARD docs for instant API lookup

In a large Rails app, being able to quickly jump between related MVC files is a huge timesaver. The Go to Definition feature handles this with ease – just right click on a model or controller name and select "Go to Definition" to jump straight to its source:

Rails Go to Definition demo

Similarly, the path auto-suggestions and schema-based completions save tons of time when working with models and views. No more typos in attribute names or needing to constantly check the schema.

Overall the Rails extension turns VS Code into a true Rails IDE. It understands the framework‘s conventions and helps you navigate your app‘s structure like a pro.

3. Solargraph – IDE-Grade Intellisense

Solargraph is the secret sauce powering Ruby and Rails Intellisense. It‘s a standalone language server that uses static analysis to provide language support features like code completion, jump to definition, and inline documentation.

While the Ruby plugin includes basic Solargraph integration, installing the full Solargraph extension unlocks its most powerful features, including:

  • "IDE-grade" autocompletion for Ruby and Rails APIs
  • Real-time linting and diagnostics to catch potential bugs
  • Detailed method and class signatures for accurate completion
  • Inline documentation via mouse hover and definition previews

The autocompletion is especially noteworthy. Solargraph performs deep analysis of your project to provide completions tailored to your specific classes, methods and libraries. It understands Ruby‘s dynamic nature and can infer far more than most basic auto-complete engines.

Take a look at this example. Note how it suggests chained methods that are likely to be called on the User class, with accurate inline method signatures and docs:

Solargraph completion demo

Solargraph also offers code "hover" actions to instantly preview documentation for any Ruby method or class, right inline. I use this constantly to quickly check what arguments a method expects or what it returns.

If you‘ve ever used a powerful Java IDE like IntelliJ, Solargraph brings that level of code insight to Ruby and Rails. It truly provides IDE-level language support.

4. VSCode Endwise – Never Forget an ‘end‘ Again

Endwise is a simple but life-changing Ruby extension. Its one job is to automatically insert end when appropriate as you type Ruby code blocks.

For example, when you write an if statement and hit enter, Endwise will automatically add the closing end and put your cursor in the middle, like so:

Endwise demo

It does the same for other Ruby blocks like do, def, module, etc.

This tiny feature has two big benefits:

  1. It prevents syntax errors from forgetting to close blocks, which is a common pitfall when you‘re first learning Ruby.
  2. It saves you from having to type end dozens of times a day. The keystrokes add up!

While it‘s a small thing, it shows how a well-designed extension can smoothly integrate with your coding workflow to save time and mental overhead. Great tools get out of the way and let you focus on the task at hand.

5. Rails DB Schema – Painless Database Interactions

For the final extension, I‘ve chosen one that helped me wrangle another critical part of any Rails app – the database.

The "Rails DB Schema" plugin by Junichi Akisaka is an absolute gem (pun intended) for working with Rails migrations, models, and schemas. It offers:

  • Schema-aware completion for ActiveRecord models, so you always have access to accurate attribute names and types
  • Autocomplete for Rails database DSL in migration files, with syntax highlighting
  • Go to Definition navigation between models and their associated schema definitions
  • Inline schema documentation on hover

Here it is in action, providing completions for model attributes read directly from the associated schema.rb file definition:

Rails DB Schema Completion

Having the schema at your fingertips while writing model logic cuts out so much context switching and cross-referencing. It also prevents bugs caused by outdated or misspelled attribute references. Any Rails engineer can tell you painful stories of debugging issues caused by a typo in a SQL query!

Similar schema-aware completion is available in migration files, with handy syntax highlighting to prevent errors:

Rails DB Schema Migration

For an added productivity boost, the extension lets you use "Go to Definition" on model classes to jump straight to their associated table definition in schema.rb. Navigating between the abstraction layers of database, model, and code is noticeably smoother.

Since databases are at the heart of most Rails apps, investing in a good workflow makes a huge difference. This extension is one of those tools that feels like cheating after you‘ve gotten used to it.

Honorable Mentions

The plugins covered so far are my personal "fab five" for Rails development in Visual Studio. However, there are a few other extensions worth installing to round out your toolkit:

  • npm Intellisense: Even in a Rails app, you likely have some JavaScript libraries managed by npm. This extension provides smart completions for import statements and other npm workflows.

  • Prettier: Prettier is an opinionated code formatter that works for a variety of languages including Ruby, JavaScript, HTML and CSS. A bit of automatic formatting can go a long way towards maintaining a consistent code style, especially on a team.

  • VSCode Ruby: Yes, another Ruby extension! This one adds a few more niceties like better syntax highlighting, block commenting, and snippet support.

Visual Studio – A Ruby IDE in Disguise?

By now you might be thinking – with all these plugins, is Visual Studio Code basically just a full-blown Ruby IDE? The answer is… pretty much!

While it might not have every bell and whistle of a dedicated tool like RubyMine, I‘ve found VS Code to cover all the essentials, and then some. The extensions ecosystem has really matured to the point where you can assemble an impressively powerful IDE from individual building blocks.

As a polyglot programmer who frequently works across Ruby, JavaScript, and other languages, I appreciate having one consistent editor for all my coding. Visual Studio Code‘s flexibility to adapt to any language or stack is a big selling point. I can use the same familiar keystrokes and workflows whether I‘m tweaking an ERB template or debugging a gnarly Node.js script.

There are also advantages to Code‘s lightweight, modular architecture. By installing only the extensions I need, I can keep my environment lean and fast. My VS Code startup time is a fraction of heavier IDEs I‘ve tried.

That said, RubyMine does offer a few creature comforts you won‘t find in a general-purpose editor. It tends to support new Rails features and APIs faster, and offers some built-in visual tools for things like database management and HTTP client testing. If you‘re working on a large, all-Ruby team, the extra cost may be worthwhile.

But for the vast majority of Rails engineers, I believe Visual Studio Code with a curated suite of extensions can be an incredibly productive IDE. Give it a spin with the plugins from this article and see how it turbocharges your Rails development!

Boost Your Ruby on Rails Workflow Today

As a Ruby on Rails developer, you already have an incredibly powerful framework at your fingertips. With the right tools and customizations, you can go from powerful to downright superhuman.

The five Visual Studio Code extensions covered here are my personal must-haves:

  1. Ruby – The best all-around Ruby language support, bar none
  2. Rails – Navigate your app‘s structure like you built Rails yourself
  3. Solargraph – IDE-grade code insights that border on mind-reading
  4. VSCode Endwise – Automatically put an end to end oversights
  5. Rails DB Schema – Database schema knowledge always in reach

These plugins have saved me more development time and head-scratching debugging sessions than I can count. Taken together, they transform VS Code from a great multi-language editor into a purpose-built Rails IDE.

I encourage every Rails developer to give them a try and see what productivity boosts await you. It only takes a few minutes to install them from the massive Visual Studio Marketplace of extensions. Best of all, they‘re completely free and open-source!

If you found this guide helpful, please share it with your fellow Ruby enthusiasts. You can also find me on Twitter [@YourNameHere] where I share more tips and insights from my journey as a Rails developer.

Here‘s to happy, productive Rails coding!

Similar Posts