Skip to content

Instantly share code, notes, and snippets.

@aaronromeo
Last active January 7, 2019 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronromeo/83da52bcdc2091f393d85f81d4f7c74c to your computer and use it in GitHub Desktop.
Save aaronromeo/83da52bcdc2091f393d85f81d4f7c74c to your computer and use it in GitHub Desktop.
My Rails init setup

The Non API version...

Generate a new app

  • Setup the app using postgres
  • Skip bundle install
  • Skip test files
rails _4.2.7.1_ new myapp -T -d postgresql --skip-turbolinks -B

Create a new PG DB role

create role myapp with createdb login password 'password1';

Modify the gemfile

  • Remove coffeescript
  • Add Babel
  • Install HAML
  • Add Rspec
  • Add FactoryGirl
diff --git a/Gemfile b/Gemfile
index 8786a17..2f9dd58 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,5 +1,5 @@
 source 'https://rubygems.org'
-
+ruby '2.3.0'

 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
 gem 'rails', '~> 5.0.0'
@@ -12,10 +12,12 @@ gem 'sass-rails', '~> 5.0'
 # Use Uglifier as compressor for JavaScript assets
 gem 'uglifier', '>= 1.3.0'
 # Use CoffeeScript for .coffee assets and views
-gem 'coffee-rails', '~> 4.2'
+# gem 'coffee-rails', '~> 4.2'
+gem 'sprockets'
+gem 'sprockets-es6'
 # See https://github.com/rails/execjs#readme for more supported runtimes
 # gem 'therubyracer', platforms: :ruby

+gem 'haml'
+gem 'haml-rails'
+
 # Use jquery as the JavaScript library
 gem 'jquery-rails'
 # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
@@ -31,6 +33,11 @@ gem 'jbuilder', '~> 2.5'
 group :development, :test do
   # Call 'byebug' anywhere in the code to stop execution and get a debugger console
   gem 'byebug', platform: :mri
+
+  gem 'pry-byebug'
+
+  gem 'rspec-rails'
+  gem 'rails-controller-testing'
+  gem 'factory_girl_rails'
 end

 group :development do
  • Set Ruby version

Get this into a git repo

git init && git add -A && git commit -m "Initial"

Setup Rspec

Since I always forget this...

bundle exec rails generate rspec:install
bundle exec rake db:migrate && bundle exec rake db:test:prepare
@aaronromeo
Copy link
Author

Looks like rails _4.2.7.1_ doesn't work for Rails 5.2.1.

This workaround might help

# make directory for new rails app
mkdir app
cd app

# specify ruby version 
echo 2.3.5 > .ruby-version

# initialize bundler (creates Gemfile)
bundler init

# specify rails version in Gemfile
gem "rails", "4.2.11"

# create rails app using specified version, and overwrite current Gemfile
bundle exec rails new . --force

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