File | Settings | General | Save files by deactivating the frame:
Select this check box to save all changed files each time you switch to another application. Removing a checkbox can lead to a conflict of changes inside and outside of RubyMine when it loses focus. In this case, RubyMine will prompt you to select the option you need. For more information, see the File Cache Context Dialog Box dialog box.

Please note that this option should be enabled by default.
source
share