-
-
Save alvinlai/4431043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 0. Make sure you have Ruby 1.9.3 installed, and optionally RVM and PostgreSQL | |
# 0.2 If you are on the Mac, make sure you have a c compiler by installing XCode Command Line Tools or gcc4.2 with homebrew | |
# https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers | |
# 0.5 Make sure you have bundler version ~> 1.2 as Rails depends on it | |
gem install bundler | |
# 1. Get edge Rails source (master branch) | |
git clone https://github.com/rails/rails.git | |
# 2. Create the rails app | |
# The --edge option will point the Gemfile to rails on github (the tip of the master branch, i.e. EdgeRails) | |
# Use the --dev option to insated point your Gemfile to your local rails checkout (useful for experimentation) | |
rails/railties/bin/rails new myapp --edge --skip-bundle --database=postgresql --skip-test-unit --skip-index-html | |
# 3. (Optional) Create rvm gemset on Ruby 1.9.3 (Rails 4 requires Ruby 1.9.3) | |
# This step will isolate the gem dependencies of the app from other gems installed on your system | |
rvm --rvmrc --create 1.9.3@myapp | |
# 4. (Optional) Install gem dependencies and put binaries under ./bin | |
# If you skip this step you need to prefix commandline commands with "bundle exec" | |
# NOTE: I had to do the following on my mac for the gcc compiler to be found when the json gem was installed: | |
# sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2 | |
bundle install --binstubs | |
# 5. Set up PostgreSQL database | |
createuser myapp | |
bin/rake db:create | |
# 6. Scaffold some model to test that the app works | |
bin/rails generate scaffold Post title:string body:text | |
bin/rake db:migrate | |
bin/rails server | |
# Add root to: 'posts#index' in config/routes.rb | |
open http://localhost:3000 | |
# 7. Create repo on github | |
# Browse to http://github.com to click the "New repository" button | |
git init | |
git add . | |
git commit -m "First commit" | |
git remote add origin [email protected]:peter/myapp.git # use the URL from github here | |
git push -u origin master | |
# 8. Deploy to Heroku | |
gem install bundler --pre # Needed to specify ruby 1.9.3 for Heroku | |
# Add gem 'thin' to Gemfile # Typical web server for Heroku deploy | |
# Add ruby '1.9.3' to Gemfile (after the source directive) | |
# Add config.assets.initialize_on_precompile = false to config/application.rb # Avoid db connect on asset precompile | |
RAILS_ENV=production bin/rake assets:precompile | |
# (See https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar for more info) | |
# NOTE: to get eventmachine (thin dependency) to install on my Mac (Mountain Lion) I had to do: | |
# sudo ln -s /usr/bin/llvm-g++-4.2 /usr/bin/g++-4.2 | |
# See: https://github.com/eventmachine/eventmachine/issues/325 | |
bundle install | |
echo "web: bundle exec rails server thin -p \$PORT -e \$RACK_ENV" > Procfile | |
git add .; git commit -m "Preparations for Heroku deploy"; git push | |
heroku apps:create peter-myapp # myapp was taken... | |
git push heroku master | |
heroku run rake db:migrate | |
heroku restart | |
heroku apps:open | |
heroku logs --tail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment