Create And Deploy A Rails App
Step 1: Change to your home directory
Step 2: Create a new Rails app
Type this in the terminal:rails new test_appType this in the terminal:cd test_appType this in the terminal:rails serverApproximate expected result:=> Booting WEBrick => Rails 3.2.x application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2010-09-30 21:04:12] INFO WEBrick 1.3.1 [2010-09-30 21:04:12] INFO ruby 1.9.3 (2012-11-10) [x86_64-darwin10.4.2] [2010-09-30 21:04:12] INFO WEBrick::HTTPServer#start: pid=24805 port=3000The greyed-out text may differ and is not important.
Step 3: Generate a database model
Type this in the terminal:rails generate scaffold user name:string email:string address:text active:boolean rake db:migrate rails server
Step 4: Use git
Type this in the terminal:git initExpected result:Initialized empty Git repository in c:/Sites/test_app/.git/Type this in the terminal:git add -AType this in the terminal:git commit -m "initial commit"Expected result:a lot of lines like create mode 100644 GemfileType this in the terminal:git logExpected result:(Your git name and "initial commit" message.)
Step 5: Deploy your app to Heroku
Step 1: Create a Heroku application from this local Rails application.Type this in the terminal:heroku createExpected result:Enter your Heroku credentials. Email: firstname.lastname@example.org Password: Uploading ssh public key /Users/smei/.ssh/id_rsa.pub Creating floating-winter-18... done, stack is cedar http://floating-winter-18.heroku.com/ | email@example.com:floating-winter-18.git Git remote heroku addedType this in the terminal:git remote showExpected result:heroku
Step 2: Prepare your rails app for deploying to Herokugem 'sqlite3'group :development, :test do gem 'sqlite3' end group :production do gem 'pg' endType this in the terminal:bundle install --without production
Step 3: Add the changes to gitType this in the terminal:git add . git commit -m "Updates for heroku deployment"
Step 4: Deploy (push) to herokuType this in the terminal:git push heroku masterExpected result:The authenticity of host 'heroku.com (220.127.116.11)' can't be established. RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'heroku.com,18.104.22.168' (RSA) to the list of known hosts. Counting objects: 60, done. Compressing objects: 100% (54/54), done. Writing objects: 100% (60/60), 79.03 KiB, done. Total 60 (delta 10), reused 0 (delta 0) -----> Heroku receiving push -----> Rails app detected Compiled slug size is 080K -----> Launching...... done App deployed to Heroku To firstname.lastname@example.org:floating-winter-18.git * [new branch] master -> masterType this in the terminal:heroku run rake db:migrateExpected result:Running rake db:migrate attached to terminal... up, run.1 Migrating to CreateUsers (20111204065949) == CreateUsers: migrating ==================================================== -- create_table(:users) -> 0.0122s == CreateUsers: migrated (0.0123s) ===========================================
Step 5: Visit your new application