Create And Deploy A Rails App
Step 1: Change to your home directory
WindowsType this in the terminal:cd c:\SitesMac or LinuxType this in the terminal:cd ~
Step 2: Create a railbridge directory
Type this in the terminal:mkdir railsbridge
Step 3: Change to your new railsbridge directory
Type this in the terminal:cd railsbridge
Step 4: 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 4.0.x application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2021-09-30 21:04:12] INFO WEBrick 1.3.1 [2021-09-30 21:04:12] INFO ruby 1.9.3 (2021-11-10) [x86_64-darwin10.4.2] [2021-09-30 21:04:12] INFO WEBrick::HTTPServer#start: pid=24805 port=3000The greyed-out text may differ and is not important.
Step 5: Generate a database model
Type this in the terminal:rails generate scaffold drink name:string temperature:integerType this in the terminal:rake db:migrateType this in the terminal:rails server
Step 6: Use git
Type this in the terminal:git initExpected result:Initialized empty Git repository in c:/Sites/railsbridge/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 7: Deploy your app to Heroku
Step 7.1: Create a Heroku application from this local Rails application.
Type this in the terminal:heroku createExpected result:Enter your Heroku credentials. Email: myemail@example.com 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/ | git@heroku.com:floating-winter-18.git Git remote heroku addedType this in the terminal:git remote showExpected result:herokuStep 7.2: Prepare your rails app for deploying to Heroku
gem 'sqlite3'
group :development, :test do gem 'sqlite3' end group :production do gem 'pg' gem 'rails_12factor' endType this in the terminal:bundle install --without productionStep 7.3: Set the root route
# root 'welcome#index'
root 'drinks#index'
Step 7.4: Add the changes to git
Type this in the terminal:git add -A git commit -m "Updates for heroku deployment"Step 7.5: Deploy (push) to heroku
Type this in the terminal:git push heroku masterExpected result:The authenticity of host 'heroku.com (75.101.145.87)' 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,75.101.145.87' (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 git@heroku.com:floating-winter-18.git * [new branch] master -> masterType this in the terminal:heroku run rake db:migrateExpected result:Migrating to CreateDrinks (20120428044153) == CreateDrinks: migrating =================================================== -- create_table(:drinks) -> 0.0084s == CreateDrinks: migrated (0.0085s) ==========================================Step 7.6: Visit your new application
Next Step:
Go on to Get A Sticker
Back to Create A Heroku Account