Skip to content

Instantly share code, notes, and snippets.

Last active January 23, 2021 22:34
Show Gist options
  • Save radavis/6539343 to your computer and use it in GitHub Desktop.
Save radavis/6539343 to your computer and use it in GitHub Desktop.
export EDITOR=subl
export PGHOST=
function rails_new() { rails new $1 && cd $1 && git init && git add . && git commit -m 'Initial commit'; }
alias migrate='rake db:migrate && rake db:rollback && rake db:migrate'
function rebuild_db_and_test() { rake db:drop && rake db:create && rake db:migrate && rake db:test:prepare && rspec spec; }
function rails_pg() {
rails new $1 -T -B --database=postgresql
cd $1
# setup rails filesystem
echo $1 > .ruby-gemset
echo ruby-2.0 > .ruby-version
# configure postgres
echo /config/database.yml >> .gitignore
mv config/database.yml config/database.example.yml
sed "s/username: "$1"/username: /g" config/database.example.yml > config/database.yml
rake db:create
cd .. && cd $1
cd .. && cd $1
rails generate rspec:install
# save progress
git init
git add .
git commit -m 'initial commit'
subl .
function add_rails_gems() {
echo "
#gem 'acts-as-taggable-on'
#gem 'carrierwave'
#gem 'devise'
#gem 'kaminari'
#gem 'ransack'
#gem 'simple_form'
#gem 'state_machine'
#gem 'stringex'
group :test, :development do
gem 'capybara'
#gem 'factory_girl'
gem 'factory_girl_rails'
gem 'launchy'
gem 'pry-rails'
gem 'quiet_assets'
gem 'rspec-rails'
gem 'shoulda-matchers'
gem 'valid_attribute'
" >> Gemfile
function add_bootstrap3() {
cp ~/Dropbox/launch/bootstrap3.0.0/css/bootstrap-theme.min.css vendor/assets/stylesheets/
cp ~/Dropbox/launch/bootstrap3.0.0/css/bootstrap.min.css vendor/assets/stylesheets/
cp ~/Dropbox/launch/bootstrap3.0.0/js/bootstrap.min.js vendor/assets/javascripts/
sed -i '' '$d' app/assets/stylesheets/application.css
echo " *= require bootstrap.min\n *= require bootstrap-theme.min\n */" >> app/assets/stylesheets/application.css
echo "//= require bootstrap.min" >> app/assets/javascripts/application.js
function remove_turbolinks() {
sed -i '' '/turbolinks/,/^$/d' Gemfile
sed -i '' '/turbolinks/d' app/assets/javascripts/application.js
sed -i '' 's@, "data-turbolinks-track" => true@@' app/views/layouts/application.html.erb
function add_foundation() {
echo "
gem 'compass-rails'
gem 'zurb-foundation', '~> 4.0.0'
" >> Gemfile
rails g foundation:install
Copy link

jmmk commented Sep 15, 2013

Without using factory_girl_rails, you have to do a bit of extra configuration (at least I did) to be able to use factories in your spec files.

sed -i '' '5a
require '''factory_girl'''
' spec/spec_helper.rb

Copy link

radavis commented Sep 16, 2013

I suppose we might as well just use factory_girl_rails, since it requires factory_girl as a dependency.

Copy link

radavis commented Sep 28, 2013

An earlier version of this script removed the following lines from application.html.erb:

<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>

This has been corrected.

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