Skip to content

Instantly share code, notes, and snippets.

@radavis
Last active January 23, 2021 22:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save radavis/6539343 to your computer and use it in GitHub Desktop.
Save radavis/6539343 to your computer and use it in GitHub Desktop.
.rails_aliases
export EDITOR=subl
export PGHOST=127.0.0.1
#export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
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
remove_turbolinks
add_rails_gems
cd .. && cd $1
bundle
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'
end
" >> 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
bundle
rails g foundation:install
}
@radavis
Copy link
Author

radavis commented Sep 16, 2013

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

@radavis
Copy link
Author

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