ironin-vsc-ruby-rails README
Simple extension for Visual Studio Code (VSC / VSCode) that adds sample Ruby and Ruby on Rails (RoR) features.
Features
Currently implmented features (as tasks or commands):
Generic features
- Install Tasks (command only)
Ruby on Rails (RoR) features
- Install Rails Debug Config (command only)
- Install rdbg VSC launch config (command only)
- Start Rails Server with
bin/rails server
- Start Rails Console with
bin/rails c
- Start Rails:
bin/dev
(assuming it's already present)
- Start Rails debug mode with:
bin/debug
(available after running Add Rails Debug Config
)
Ruby features
- Run Ruby File
- Show Ruby Version
- Bundle Install
- Install Debug Gem
Easily add new tasks and commands by modifying rubyTasks.json
Install Tasks
Creates or extends .vscode/tasks.json
with all this extensions tasks.
It only adds tasks that are not already present in the file by comparing the command
.
Unfortunately the tasks added dynamically are not visible when you open Tasks: Run Tasks
, only in Show All Tasks
. Installing tasks make them more accessible.
The advantage of the extension tasks (over the installed) is that they are available only if their condition are met (eg. if bin/rails
exists for Run Rails Server
etc).
Install rdbg VSC launch config
Creates .vscode/launch.json
if not present.
Adds the following config to .vscode/launch.json
if not present.
With debug
gem installed (Install Debug Gem
command) you can enable debugging for Ruby scrips and RoR apps by simply placing breakpoints in VSC and running Attach with rdbg
.
{
"type": "rdbg",
"name": "Debug current file with rdbg",
"request": "launch",
"script": "${file}",
"args": [],
"askParameters": true
},
{
"type": "rdbg",
"name": "Attach with rdbg",
"request": "attach"
}
Add Rails Debug Config
Assuming bin/dev
and Procfile.dev
exists - eg. when RoR app has Docker or devcontainers configured.
Duplicates bin/dev
to bin/debug
and makes it execute Procfile.debug
instead of Procfile.dev
.
Duplicates Procfile.dev
to Procfile.debug
and adds rdbg
to the web
process.
Start Rails Server
Starts Ruby on Rails server.
bin/rails server
Start Rails Console
Starts Ruby on Rails console.
bin/rails c
Run Ruby File
Runs the current Ruby file in the terminal.
ruby ${file}
Bundle Install
Runs bundle install
in the terminal.
bundle install
Install Debug Gem
Installs the debug
gem in the terminal.
gem install debug
Show Ruby Version
Shows the Ruby version in the terminal.
ruby -v