How to make RubyMine aware of Cucumber steps defined in gems

If your Ruby project includes a gem like Spreewald that comes with some external step definition, RubyMine does not know about them by default and will highlight the step as an undefined reference:

Image

To link these external step definitions to RubyMine, add the corresponding gems to your RubyMine-Settings:

  • Go to Settings (ctrl + alt + s)
  • Go to Languages and Frameworks
  • Go to Cucumber
  • There, add your gem (e.g "spreewald") via the little "+" from the b...

Rubymine FileType mismatch

If your Rubymine does not recognize a file type correctly although you have entered the unmistakeable file extension like material_orders_controller.rb, this may help you:

Causing the Problem

Sometimes you create a new file and forget to enter the ending like material_orders_controller
Rubymine handles such files per default as simple txt files.
You delete this file and create a new one with correct ending: material_orders_controller.rb. But still Rubymine treats this file as text file, no highlighting is available.

What happene...

RubyMine: How to add a german spell checker

Since the Spell checker german dictionary plugin is not maintained anymore, here is another way to use a german dictionary.

  1. Install the Hunspell plugin and restart Ruby Mine
  2. Run sudo apt install hunspell-de-de
  3. Select /usr/share/hunspell/de_DE.dic in File > Settings > Editor > Spelling > Custom Directory +

![Screenshot_from_2018-10-17_16-47-03.png](https://makandracards.com/makandra/57341-rubymine-how-to-add-german-spell-checker...

RubyMine: You can disable inspections you don't care about

When you find yourself constantly ignoring a RubyMine warning, you can simple disable that warning and de-clutter your editor. E.g. in my Cucumber scenarios RubyMine underlines 90% of all lines because it does not know about spreewald, making the file really hard to read.

You can disable any unwanted inspection by opening File / Settings / Editor / Inspections and searching for the warning text.

What you disable or keep is up to your personal preference. I personally disable at least the following...

How to add a custom dictionary to Ruby Mine

  1. Download the dictionary from http://www.winedt.org/dict.html, e.g. http://www.winedt.org/dict/de_neu.zip
  2. unzip de_neu.zip
  3. mkdir ~/Documents/dic
  4. iconv -f UTF-16 -t UTF-8 de_neu.dic -o ~/Documents/dic/de_neu_utf8.dic
  5. In RubyMine: Go to Settings (CTRL + ALT + S) > Editor > Spelling > Dictionaries and add the folder ~/Documents/dic

Postgres: How to force database sessions to terminate

If another session is accessing your database you are trying to reset or drop you might have seen the following error:

PG::ObjectInUse: ERROR:  database "foo_development" is being accessed by other users
DETAIL:  There is 1 other session using the database.

This could be the rails server, rubymine and many more. Beside terminating the session connection manually you can also find out the pid and kill the process.

1. rails db
2. SELECT * FROM pg_stat_activity;

datid            | 98359
datname          | foo_developm...

Guide: How to use our (maybe in future) default rubocop config

Follow the instructions here.

PRs at makandra/rubocop-config are welcome. Also check the issue tracker.

RubyMine

Since version 2017-1 RubyMine runs cops in the background, and displays RuboCop offenses the same way as it does RubyMine inspections. (...

RubyMine: Better soft wraps

Sometimes your code has long lines:

describe 'foo' do
  describe 'bar' do
    really_long_line_really_long_line_really_long_line
    another_line

When you're working with multiple editor panes, such code will often be wider than the pane area:

describe 'foo' do                |
  describe 'bar' do              |
    really_long_line_really_long_|
    another_line                 |

To help with this you can activate Soft wraps in the RubyMine options under General → Editor .

Your code will now look like this:

des...

How to fix: RubyMine / IntelliJ "find file" dialog losing focus on awesome wm

Many of our developers love to use the "awesome" window manager on Linux. However, RubyMine dialogs occasionally defocus while typing.

Here is a fix for that, tested on awesome 3.4, 3.5 and 4.0 (Ubuntu 14.04 and 16.04).

Problem

Consider the following:

  1. Press Ctrl+Shift+N
  2. "Find file" dialog opens
  3. Type to search, file list appears
  4. Type more, file list is being replaced

If your mouse pointer hovers the file list, the main window is focused when the list is being replaced (or simply when it shrinks and your mouse pointe...

Prevent RubyMine from reformatting pasted code

When you paste copied code with CTRL+V, RubyMine will change the indentation of the pasted code. You can prevent this by pasting with CTRL+ALT+Shift+V instead ("Paste Simple").

To change this behavior entirely, you can open your settings and navigate to Editor / General / Smart Keys. Here you can select one of three options for Reformat on paste:

  • None
  • Indent Each Line (default)
  • Indent Block
  • Reformat Block

You might want to try "Indent Block".

How to fix: RubyMine occasionally no longer accepts keyboard input

From time to time, RubyMine suddenly did not accept any keyboard input and felt crashed, while mouse interaction was still possible. This apparently happens to all IntelliJ IDEs, especially on Ubuntu 14.04.

I've managed to fix it by having a shell script that exports XMODIFIERS="" when launching RubyMine, like this:

#!/bin/sh
XMODIFIERS= /home/arne/rubymine/bin/rubymine.sh

It has been working reliably for me ever since, at least until RubyMine 8.

An alternate solution suggested on the [Jetbrains issue tracker](https://youtrack....

RubyMine's clipboard can hold more than one string

By pressing Ctrl + Shift + V you can select a recently copied string for pasting.

List of Helpful RubyMine Shortcuts

Navigation

CTRL + SHIFT + ALT + N
: Search for any symbol in your application, like CSS classes, Ruby classes, methods, helpers etc.

CTRL + SHIFT + N
: Search for filename in your application (also dependencies)

CTRL + E
: Open a list of recently opened files

ALT + POS1
: Open a the navigation bar as a context menu. Allows you to quickly navigate between files.

CTRL + G
: Go to line

Actions

CTRL + SHIFT + A
: Find ...

Faster debugging with RubyMine macros

In my RubyMine I have recorded two macros for debugging and linked them to some keyboard shortcuts. Since I believe everyone could benefit from having those I wanted to share this.

The first one simply inserts

binding.pry

and the second one

.tap { |object| binding.pry }

for when you do not have a reference to the object you want to inspect.

In order to record a macro you simply follow the path Edit > Macros > Start Macro Recording.

Then you simply type binding.pry or whatever you want to record and stop recor...

Disable automatic code suggestions in RubyMine

To disable the mostly useless automatic suggestion popups in RubyMine, go to File / Settings, then to Editor / General / Code Completion and uncheck Auto-display code completion.

You can still open the popup by pressing CTRL + Space. And you probably want to use Context-dependent word expansion instead, anyway.

Rubymine: Code folding

Code folding is a very useful feature to me. It gives me a quick overview over a file and keeps me from scolling like a hamster in its wheel.

Keyboard shortcuts:

Collapse/expand current code block

strg -/+

Collapse/expand the whole file

strg ctrl -/+

When diving into Cucumber features or huge Ruby classes, I usually collapse all and the gradually expand what I need.

How to: Context-dependent word expansion in RubyMine

One of the many useful features of TextMate is autocompletion of words. If I were in TextMate right now, I could write "au[tab]", and it would complete it to "autocompletion". RubyMine can do this, too. When you write a word (e.g. a variable name), just hit ALT + / repeatedly and it will offer all completions for the letters you typed. This action is called Cyclic Expand Word in RubyMine / IntelliJ IDEA.

This feature keeps you from mistyping variable names, saves you keystrokes and speeds up development. ~10 keystrokes to the price ...

Rubymine 7: Howto disable backspace deletes lines instead of whitespaces

RubyMine 7.1:

Settings -> Editor -> General -> Smart Keys -> Unindent -> To nearest indent position

RubyMine 7.0:

Settings -> Editor -> General -> Smart Keys -> Backspace smart indent -> uncheck

Search everywhere in RubyMine

Have you tried the Search everywhere dialog? You can open it by pressing Shift twice.

search_everywhere.png

The new Modularity 2 syntax

We have released Modularity 2. It has many incompatible changes. See below for a script to migrate your applications automatically.

There is no does method anymore

We now use traits with the vanilla include method:

class Article < ActiveRecord::Base
  include DoesTrashable
end

When your trait has parameters, use square brackets:

class Article < ActiveRecord::Base
  include DoesStripFields[:name, :brand]
end

Note how you ...