Skip to content

Instantly share code, notes, and snippets.

@dwa012
Last active December 28, 2018 16:26
Show Gist options
  • Save dwa012/936ce34deb980c9d04bf to your computer and use it in GitHub Desktop.
Save dwa012/936ce34deb980c9d04bf to your computer and use it in GitHub Desktop.
Rails project setup with Vagrant

###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 it lab1, 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
  • 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

enter image description here

Note: When choosing the app, remember to select the containing folder of the application.

enter image description here

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.

enter image description here

####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 step 2 on the following image. Once the menu pops up, select New remote... in step 3.

enter image description here

  • You should see a popup similar to the following.

enter image description here

  • Select the Vagrant radio button at the top, which should change the popup to look like this.

enter image description here

  • In the Ruby interpreterpath erase the /usr/bin/ruby text and paste the following in.
/home/vagrant/.rvm/gems/ruby-2.2.2@global
  • The popup should now be similar to the following.

enter image description here

  • 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

enter image description here

If you wish, you can open RubyMine and start/stop the vagrant vm.

####2. To open a shell into the VM, we can use the terminal widget in RubyMine which will allow you to perform vagrant ssh

enter image description here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment