Skip to content

Instantly share code, notes, and snippets.

@stevenyap
Last active March 1, 2018 02:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save stevenyap/7037829 to your computer and use it in GitHub Desktop.
Save stevenyap/7037829 to your computer and use it in GitHub Desktop.
Describes best practices in starting a ROR project

These are steps to setup a new project in ROR.
You must configure and install your Gems individually instead of copying the Gemfile from a previous project.

Refer to Heroku setup if you want to push your project to Heroku.

Setup directory

# Create directory in ~/workspace
mkdir ./testproject
cd ./testproject

# Create .ruby-version and .ruby-gemset
touch .ruby-version
touch .ruby-gemset
echo ruby-2.0.0 > .ruby-version
echo testproject > .ruby-gemset

# Rails gem will be installed in project gemset
gem install rails --no-rdoc --no-ri

# creates the new ROR project
rails new .

Edit .gitignore

# Ignore Rubymine
/.idea

# Ignore mac stupid DS_Store
*.DS_Store

# Ignore VIM swp files
*.swp
*.swo

Edit Gemfile to setup testing

  • Note: Install each gem ONE-BY-ONE and run their configuration/installer as needed
  • Run "bundle install" to install the gem
  • Note: Set the Ruby SDK in Rubymine preference > Ruby SDK and Gem to your project RVM!!
group :development, :test do
  gem 'pry'
  gem 'pry-plus'
  gem 'pry-rails'

  gem 'rspec-rails' # After bundle, run: rails generate rspec:install
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'factory_girl_rails'
  gem 'shoulda'
  gem 'awesome_print'
  gem 'capybara' # add "require 'capybara/rspec'" to spec_helper
  gem 'selenium-webdriver'
end

Setup Github locally

git init .
git add .
git commit -m "Inital Commit"

Setup Github remotely

  • Create a new repository at www.github.com
  • Get the remote repository link
git remote add origin <respository_url>

# Push your source to github.com
git push -u origin master

Further good practices

  • Set your timezone explicity in config/application.rb eg. config.time_zone = 'Singapore'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment