Skip to content

Instantly share code, notes, and snippets.

@RenatoRosaFranco
Last active August 29, 2018 14:27
Show Gist options
  • Save RenatoRosaFranco/9e561a0610bfeede2a7ef2560e95910e to your computer and use it in GitHub Desktop.
Save RenatoRosaFranco/9e561a0610bfeede2a7ef2560e95910e to your computer and use it in GitHub Desktop.
Basic rails environment pre-build
#!/bin/bash
# set your own routine here
prepare(){
bundle install
if [ $1 != 'production' ]; then
rails db:drop RAILS_ENV=$1
fi
rails db:create RAILS_ENV=$1 && rails db:migrate RAILS_ENV=$1
rails db:seed RAILS_ENV=$1
rspec; rubocop; rails_best_practices; brakeman
echo "environment prepapred as $1"
}
# here is rails default environments
# development, test, production
if [ $1 = 'development' ]; then
prepare
elif [ $1 = 'test' ]; then
prepare
elif [ $1 = 'production' ]; then
prepare
else
echo "Unknow environment"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment