Why do/don’t I need to map additional ports for debugging? I put up a sample Sinatra app that’s set up for debugging on GitHub. Debugging should then work as normal, assuming you have the gems and other setup done. The fix is simply clicking “Add Configuration” and selecting a template in the case of Sinatra, for example, I’d select “Rack”, modify any options and click “Create configuration”. This may not be the case for other frameworks, or no framework at all. When RubyMine detects Rails, it automatically sets up run/debug configurations. Sadly, I ran into a lot of issues setting this up across different projects. When the breakpoint is hit, you’re presented with a rich, visual debugger. Add a breakpoint somewhere by clicking in the gutter and start debugging by clicking on the little green bug icon. You can have RubyMine do this for you, or simply docker-compose run web bundle.
Having set up the correct interpreter, you’ll get autocompletion, documentation and jump actions across your codebase and gems.ĭebugging support requires two gems to be added to your Gemfile: group :development, :test do Note that it won’t stop them when closing the project. RubyMine will keep your main container and any it depends on running whilst the project is open. If not, check that you’re not running any other containers that might conflict, and that you’ve told RubyMine to bring the containers up if they’re not running (see the “Ruby Docker Integration"settings page. If all is well, RubyMine will start your container and you should see a background task kick off to index your gems. If anyone at JetBrains is reading, this would be a candidate for improvement. Try to make a habit of double-checking this with docker ps and bringing them down before clicking “OK”. This means that another, unrelated docker container will be running, whose ports may conflict. Note that if you’ve already added remote interpreters for other projects, RubyMine might try to use one of those when you first open the new project. That interpreter will be added to the list 1. Click OK and you should see a couple of progress indicators fly by. RubyMine should pre-fill most fields here, but you’ll need to select the “Service” - or container - that your rails server is running inside. Click the “+” and select “Docker Compose”. Head to Settings ▸ Languages & Frameworks ▸ Ruby SDK and Gems. The first step is to set the correct Ruby interpreter, which lives in our Docker container. Now stop those containers and open the project in RubyMine. Running docker-compose up and navigating to localhost:3000 shows me the standard Rails welcome page.
Rubymine terminal install#
RUN apt-get update -qq & apt-get install -y postgresql-clientĬommand: bash -c "rm -f tmp/pids/server.pid & bundle exec rails s -p 3000 -b '0.0.0.0'" Let’s start with a basic Rails API project with two containers: one for the app and one for the DB. Unfortunately I had some problems setting up Ruby/Rails projects running in Docker containers to work with RubyMine’s debugging features, so I’ve documented how I did it and some of the issues I ran into. This time I’m making a concerted effort to learn its feature set and make them work for me, and so far I’m thoroughly impressed. I’ve played around with it in the past, but always ended up back on vim for various reasons. JetBrains RubyMine 2020.Lately I’ve been experimenting with RubyMine. RubyMine can now create a new test for any class, replicating the directory structure based on the path to the test subject. In the Variables view of the debugger, you can now pin variables’ fields to the top and see their values in the variable’s representation. To try this feature out, enable the flag in the Experimental Features dialog. Once an input command is matched, it is highlighted and you can press Ctrl-Enter to open a particular UI with the parameters fetched from the command. RubyMine’s terminal can now parse various commands. As always, RubyMine automatically creates corresponding run/debug configurations for the tasks that were run. Starting with v2020.1, you can run, debug, and profile your tasks right from the gutter menu. Running and debugging Running Rake tasks from the gutter In the Structure view ( Ctrl+7), you can filter out the variables to see only the methods. You can also search for usages ( Alt+F7) of a super method. Navigate | Go to Super Method ( Ctrl+U) now allows you to select the exact super method you want to navigate to. To make navigation more seamless, we’ve also unified the look of the navigation popup and made it more compact.
You can now navigate between Rails entities and a DB schema.
Navigation Navigation between Rails entities