Glimmer

Faint insights into (mostly) the world of automation

Make a New Rails 3.2 App in the VM Environment

| Comments

After installing the VM on the computer, one can make a new Rails App by the following process:

  • Go to the machine directory in your host machine using the command line
  • Start up the VM if it is not running vagrant up
  • Connect to the machine vagrant ssh
  • First time only, tell git who you are

       git config --global user.email "you@example.com"
       git config --global user.name "Your Name"
    
  • Change to the directory that is shared between the guest OS and the host OS cd /vagrant

  • Create a new Rails application without running bundler rails new appname --skip-bundle
  • Install git’s tracking repository git init appname
  • Change to the application directory cd appname
  • Update .gitignore to skip tracking database.yml You can edit this on the host side rather than the OS side if you like your local editor better but use one that likes Unix line endings (i.e. NOT Notepad).
.gitignore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile ~/.gitignore_global

# Ignore bundler config
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

# Ignore database.yml
/config/database.yml
  • Move the code to check in to the staging area git add .
  • Commit the code the repository git commit -m "Initial commit after ignoring database.yml"
  • Make a copy of database.yml for archival cp config/database.yml config/database-example.yml
  • Modify the Gemfile to include thin, theracer, and quiet_assets gems.
Gemfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
source 'https://rubygems.org'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'thin'
gem 'quiet_assets', :group => :development


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'


  • Run bundle to lock in the gemfiles using the local version of the gems bundle install --local
  • Start up the Rails app rails s
  • On the host side, point the browser to http://192.168.33.10:3000 and ensure that the base Rails “Welcome aboard” is visible.

Updated 7 June 2013 after presentation to class — correcting two typos.

Comments