Skip to end of metadata
Go to start of metadata

This tutorial should help people, who are new to Rails, to configure their environment before starting to develop a RoR application with RubyMine on Windows. It doesn't depend on Windows and RubyMine versions.

1. Install Ruby

1. Rubyinstaller + Devkit

All Ruby installers are available here. To be able to install Rails you have to install and configure DevKit.
Please follow these instructions. Pay attention to the fact that DevKit version should correspond with Ruby. You could find this information here.

Hint: to check yourself try to install any gem, which needs to build native extensions (e.g. gem ‘json’).

2. Using RVM or rbenv + Vagrant

This method allows you to use any Ruby regardless of whether it's supported or not on Windows, you even don't need to care about Devkit version. RubyMine provides you with an ability to init Vagrant in your project and run Vagrant hosts via RubyMine.

Hint: check this tutorial to see how to use Vagrant integration and Remote SDK in RubyMine.

3. Rails Installers

The fastest way to install Ruby + DevKit + Rails with all dependencies (but with a certain version of Ruby and Rails) is available here

4. Ruby version manager on Windows

There are no Ruby version managers at the moment, which we can recommend. RubyMine supports pik (https://github.com/vertiginous/pik), in this case Ruby versions, managed by it, will be detected on the start. However, this manager is no longer maintained.

2. Install Rails

Note: we recommend to use first two ways.

1. In RubyMine

RubyMine provides an ability to install Rails while creating a new application. Use Install Rails gem option:

Hint: RubyMine doesn't allow to use remote Rubies while a new project is being created. It's possible to configure remote Ruby SDK only for existing projects.

2. RailsInstallers

In case of using RailsInstaller you will already have Rails.

Hint: not the best option if you need a specific Rails version.

3. System Command line

This way doesn't have any limitations. If you have several Rubies and want to switch Ruby in the system command line (giving you don't have any Ruby version manager) use: set PATH=c:\….\bin;%PATH%. Then run 'gem install 'rails''.

Hint: it's possible to use Terminal within RubyMine.

4. Bundler (bundler.io)

Put Rails gem into the Gemfile of already existing application and run 'bundle install' in the folder of the project. If you'd like to use a certain Rails version, specify it in the Gemfile to install it into SDK.

Hint: it's possible to use all Bundler's options within IDE. See help.

Note: we recommend to use Bundler, because in case of projects with a lot of gems it is much better: it provides an ability to keep several gem's versions and use only bundled to the project. Moreover, Bundler resolves by itself all gem dependencies while installing new gems.

3. Create and run Ruby on Rails application

1. In RubyMine

You could create a new project by following 'Create new project' wizard from RubyMine Welcome screen, or via File | New Project... See help topic. You will be able to select Ruby SDK and Rails version. In the root of the project you could see an additional folder '.idea' with current configuration. This folder keeps information about settings, Run/Debug Configurations, module types and etc. By default it's hidden from the Project View 'Project', but present in the Proejct View 'Project files':

Every new Rails project is created with pre-defined Run/Debug configurations 'Development:project' and 'Production:project' and two Rake tasks for TestUnit and Rspec tests.

To run your application just click Run button for the Rails Run/Debug configuration, it will run Rails server and you will be able to open your project in browser.

2. In the command line

For example:
~$ rails new <project_name> - creates new RoR application in the current directory.
~$ bin/rails server - run Rails server in the current project's folder.

You can find all the basic commands here. Projects created in the command line can be opened in RubyMine using 'Open' option on the Welcome screen or 'File | Open...'. It will create .idea folder in the root of the project and then you will be able to run/debug/test your application.

  • No labels