Making a new Rails app using the Vagrant Ruby interpreter
Note: There a number of shell commands that you will need to run, which are indicated with the grey background and monospaced text.
Anytime you see the following
<text>
, your are to substitute it with something of your own choosing. Ex. If you are making a directory for Lab 1 then name itlab1
, something so you can tell what the rails app is for.Windows users: You will need to use the Cygwin Terminal app to follow this guide
Creating the app via the terminal
- Create a new directory for the your Rails project
mkdir -p ~/Development/su15/CS4990/<name>
- Navigate to the newly created directory
cd ~/Development/su15/CS4990/<name>
- Get the Vagrantfile from the server
curl -o Vagrantfile http://www.cs.uno.edu/~daniel/boxes/4990_SU15/Vagrantfile
- Start the vagrant VM
vagrant up
- Once the VM is booted, open a shell for the VM
vagrant ssh
- Create the Rails app
rails new ~/workspace -d postgresql
- Create and initialize the database
rake db:create rake db:migrate
- Exit the VM
exit
Setting up RubyMine
We are going setup RubyMine to use the Ruby interepter and Rails enviroment in the vagrant VM. You only need to do this the first time, for each new Rails project.
1. Open RubyMine and open the project folder
Note: When choosing the app, remember to select the containing folder of the application.
Note: You will some errors when you first open the project, similar to the following image. You can ignore them, since we are about to fix it in the next step.
2. Next we need to configure the remote Ruby intepreter
- Open the preferences, and navigate to
Ruby SDK and Gems
Tip: You can use the keyboard shortcurts to open the preferences. OSX:
⌘ Comma
, Windows/Linux:Ctrl+Alt+S
- Once you have selected
Ruby SDK and Gems
, add a new remote with the small+
symbol in step2
on the following image. Once the menu pops up, selectNew remote...
in step 3.
- You should see a popup similar to the following.
- Select the Vagrant radio button at the top, which should change the popup to look like this.
- In the
Ruby interpreterpath
erase the/usr/bin/ruby
text and paste the following in.
/home/vagrant/.rvm/gems/ruby-2.3.1@global
- The popup should now be similar to the following.
Click
OK
to close the window.If it is all correct, then RubyMine should show some progress dialogs while it is setting up the interpreter settings.
Working with vagrant inside of RubyMine
1. We can start and stop the vagrant VM from within RubyMine, once the previous section is finished
If you wish, you can open RubyMine and start/stop the vagrant vm.