Skip to content

Instantly share code, notes, and snippets.

@kibyegn
Created December 2, 2016 08:33
Show Gist options
  • Save kibyegn/aad667c745521fa11421b23eb6ed4aac to your computer and use it in GitHub Desktop.
Save kibyegn/aad667c745521fa11421b23eb6ed4aac to your computer and use it in GitHub Desktop.
Rails new app Cheat sheet
1. Install RVM
$ \curl -L https://get.rvm.io | bash -s stable --ruby
2. Install Ruby
$ rvm install ruby
$ rvm --default use ruby-2.3.3
3. Install Javascript runtime
$ sudo apt-get install nodejs
4. Check gem manager is installed
$ gem -v
5. Update gem manager if need be
$ gem update --system
6. Disable downloading of gem documentation (Nobody uses installed documentation)
$ echo "gem: --no-document" >> ~/.gemrc
*Adds the line gem: --no-document to the hidden .gemrc file in your home dir.
7. Install bundler
$ gem install bundler
8. Install Nokogiri gem in the RVM global gemset:
$ gem install nokogiri
9. Install Rails into project-specific gemsets, for each project to have the appropriate version of Rails.
Make a gemset just for the current stable release:
$ rvm use ruby-2.3.3@rails5.0 --create
10. Install the latest stable version
$ gem install rails
$ rails -v
11. Install a specific rails version
$ gem install rails --version=3.2.18
$ rails -v
12. Here’s how to create a project-specific gemset, installing Rails, and creating a new application.
$ mkdir myapp
$ cd myapp
$ rvm use ruby-2.3.3@myapp --ruby-version --create
$ gem install rails
$ rails new .
* Popular options;
--database=postgresql # Preconfigure for PostgreSQL database
-T # Skip Test::Unit files
--api # API only app
13. Set up git
$ git init
$ git add .
$ git commit -m "Initial commit"
14. Set Ruby version in Gemfile
ruby '2.3.3'
15. Set up preferred test and development gems
group :development, :test do
gem 'rspec-rails'
end
group :test do
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'faker' #some older RubySnacks reference 'ffaker'
gem 'simple_bdd'
gem 'shoulda-matchers'
end
16. Install the gems
$ bundle
17. Edit config/database.yml with preferred database and database names
18. Create database
$ rails db:create #rake db:create still works too
19. Install rspec
$ rails generate rspec:install
20. Commit set up
$ git add .
$ git commit -m "Set up app with development gems, rspec, and pg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment