Ruby on Rails Extension Pack (by RailsNotes)
SPONSOR: RailsNotes UI — templates & components for Ruby on Rails apps (railsnotesui.xyz)
ARTICLE: A decent VS Code + Ruby on Rails setup (railsnotes.xyz)
Quickly setup VS Code for Ruby on Rails development with this extension pack.
This extension pack installs the following extensions:
- [Language Server]
- [LSP Integrations]
- [Linting / Formatting]
- [Debugger]
- [ERB formatting]
Installation
Install the following gems globally so they're available for their respective extension —
gem install solargraph rufo ruby-lsp-rails
Note: If you're using the rubocop or standard extensions, you need to add their respective gem to your Gemfile for their extension to pick them up.
bundle add standard
bundle add rubocop
To use the rdbg/debugger extension, set the environment variable in your Rails app:
RUBY_DEBUG_OPEN=true
If you're using a Procfile.dev , you'd do this (so that you can connect to debugger instances from either process):
web: RUBY_DEBUG_OPEN=true bin/rails server -p 3000
sidekiq: RUBY_DEBUG_OPEN=true bundle exec sidekiq
...
Then open the VS Code "Run and Debug" menu, click "create a launch.json file" and pick "Ruby (rdbg)" to create a file with the correct configuration.
I've written an in-depth guide here — Using Rails debugger/rdbg with VS Code.
| |