Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
LESSON 2RVM, GIT, RAILS, HEROKUPavel Tsiukhtsiayeugithub.com/paveltyk
TODO• Git   • Install   • Configure• RVM   • Install RVM   • Install Ruby   • Create Gemset• Rails   • Install   • Generat...
Git :: install• $ sudo apt-get install git-core
Git :: configure• $ git config --global user.name "PavelT"• $ git config --global user.email paveltyk@gmail.comWhere does ...
Git :: configure• $ git config --list• user.name=PavelT• user.email=paveltyk@gmail.com• color.ui=true• push.default=tracki...
Git :: install and configure• Q&A?
RVM :: install• $ sudo apt-get install curl• $ curl –L https://get.rvm.io | bash –s stable• For RVM to work properly, you ...
RVM :: install Ruby• $ rvm requirements• Requirements for Linux "Ubuntu 12.04.1 LTS”• ………• Additional Dependencies:• # For...
RVM :: install Ruby• $ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zli...
RVM :: install Ruby• $ rvm list known• # MRI Rubies• [ruby-]1.8.6[-p420]• ...• [ruby-]1.9.3[-p194]• ...• # Jruby• ...• $ r...
RVM :: gemset• $ rvm use 1.9.3• $ which ruby• /home/pavelt/.rvm/rubies/ruby-1.9.3-p194/bin/ruby• $ rvm gemset create first...
RVM• Q&A?
Rails :: install• $ gem install rails• Fetching: i18n-0.6.1.gem (100%)• Fetching: rails-3.2.8.gem (100%)• ...• 29 gems ins...
Rails :: new app• $ rails new first-app• create README.rdoc• create Rakefile• ……• Fetching gem metadata from https://rubyg...
Rails :: app skeleton (partial)• app/ - core application code (controllers, views, models…)• config/ - application configu...
Git :: init repo & initial commit• $ cd first-app• $ git init• Initialized empty Git repository in /home/pavelt/projects/f...
Git :: add files & commit• $ git status• # On branch master• # Untracked files:• # (use "git add <file>..." to include in ...
Git :: add files & commit• $ git add .• git commit - m ’Initial rails project’
Rails :: start server• rails s• => Booting WEBrick• => Rails 3.2.8 application starting in development on    http://0.0.0....
Rails :: http://localhost:3000
Rails :: if rails server failed• If failed with:• home/pavelt/.rvm/gems/ruby-1.9.3-p194/gems/execjs- 1.4.0/lib/execjs/runt...
Heroku• What is Heroku?• Heroku is a cloud application platform – a new way of    building and deploying web apps. (Heroku...
Heroku :: deployment• How to deploy to Heroku?• Simply push to master branch of your Heroku git repo• $ git push heroku ma...
Heroku :: install & configure• $ gem install heroku• Register at Heroku sign up page• https://api.heroku.com/signup• $ her...
Heroku :: first app• $ heroku create pavelt-first-app• Creating pavelt-first-app... done, stack is cedar• http://pavelt-fi...
Heroku :: first app• Go to http://pavelt-first-app.herokuapp.com
Heroku :: first app• $ git push heroku master• The authenticity of host heroku.com (50.19.85.156) cant be    established.•...
Heroku :: first app• $ heroku keys:add• Could not find an existing public key.• Would you like to generate one? [Yn] y• Ge...
Heroku :: first app• Counting objects: 73, done.• Compressing objects: 100% (58/58), done.• ….• -----> Heroku receiving pu...
Heroku :: first app• Remove `gem ‘sqlite3’` line from ./Gemfile, update bundle and commit• $ bundle install• git commit -a...
Heroku• Q&A?
Tips & Tricks :: .rvmrc• Automatically change Ruby version and Gemset• ./.rvmrc• rvm use 1.9.3@first-app --create
Tips & Tricks :: disable Ri & RDoc• How to disable Ri and Rdoc?• ~/.gemrc• install: --no-ri --no-rdoc• update: --no-ri --n...
Tips & Tricks :: informative prompt• How to make prompt more informative?• ~/.bashrc•   export GIT_PS1_SHOWDIRTYSTATE=true...
GIT, RVM, FIRST HEROKU APP
GIT, RVM, FIRST HEROKU APP
GIT, RVM, FIRST HEROKU APP
GIT, RVM, FIRST HEROKU APP
Nächste SlideShare
Wird geladen in …5
×

GIT, RVM, FIRST HEROKU APP

1.571 Aufrufe

Veröffentlicht am

Altoros training #2

Veröffentlicht in: Technologie
  • Loggen Sie sich ein, um Kommentare anzuzeigen.

GIT, RVM, FIRST HEROKU APP

  1. 1. LESSON 2RVM, GIT, RAILS, HEROKUPavel Tsiukhtsiayeugithub.com/paveltyk
  2. 2. TODO• Git • Install • Configure• RVM • Install RVM • Install Ruby • Create Gemset• Rails • Install • Generate project • First commit • Start server• Heroku • Install & Configure • Push Rails app to Heroku • Make it WORK• Tips & Tricks
  3. 3. Git :: install• $ sudo apt-get install git-core
  4. 4. Git :: configure• $ git config --global user.name "PavelT"• $ git config --global user.email paveltyk@gmail.comWhere does git store its settings?• /etc/gitconfig (--system)• ~/.gitconfig (--global)• .git/config
  5. 5. Git :: configure• $ git config --list• user.name=PavelT• user.email=paveltyk@gmail.com• color.ui=true• push.default=tracking• $ git config user.name• PavelT• At least have this 4
  6. 6. Git :: install and configure• Q&A?
  7. 7. RVM :: install• $ sudo apt-get install curl• $ curl –L https://get.rvm.io | bash –s stable• For RVM to work properly, you have to set the Run command as login shell checkbox at Edit / Profile Preferences / Title and Commands in Gnome terminal• More details here: https://rvm.io/integration/gnome-terminal
  8. 8. RVM :: install Ruby• $ rvm requirements• Requirements for Linux "Ubuntu 12.04.1 LTS”• ………• Additional Dependencies:• # For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following: build-essential openssl libreadline6• ruby: /usr/bin/apt-get install libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
  9. 9. RVM :: install Ruby• $ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
  10. 10. RVM :: install Ruby• $ rvm list known• # MRI Rubies• [ruby-]1.8.6[-p420]• ...• [ruby-]1.9.3[-p194]• ...• # Jruby• ...• $ rvm install 1.9.3
  11. 11. RVM :: gemset• $ rvm use 1.9.3• $ which ruby• /home/pavelt/.rvm/rubies/ruby-1.9.3-p194/bin/ruby• $ rvm gemset create first-app• $ rvm gemset use first-app• How to easily switch gemsets & Ruby versions [Tips & Tricks]
  12. 12. RVM• Q&A?
  13. 13. Rails :: install• $ gem install rails• Fetching: i18n-0.6.1.gem (100%)• Fetching: rails-3.2.8.gem (100%)• ...• 29 gems installed• Successfully installed i18n-0.6.1• ...• Installing ri documentation for i18n-0.6.1..• Installing RDoc documentation for rack-cache-1.2...• Ri and RDoc are slow [see Tips & Tricks]
  14. 14. Rails :: new app• $ rails new first-app• create README.rdoc• create Rakefile• ……• Fetching gem metadata from https://rubygems.org/.........• Using rake (0.9.2.2)• Using i18n (0.6.1)• …..• Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
  15. 15. Rails :: app skeleton (partial)• app/ - core application code (controllers, views, models…)• config/ - application configuration• db/ - DB related files (migrations, seeds, etc)• lib/ - library modules• log/ - application log files• public/ - publicly accessible data• Gemfile - app gem requirements• .gitignore – patterns for files that should be ignored by git
  16. 16. Git :: init repo & initial commit• $ cd first-app• $ git init• Initialized empty Git repository in /home/pavelt/projects/first-app/.git/• $ git commit --allow-empty -m Initial commit’• [master (root-commit) 6f32ce8] Initial commit
  17. 17. Git :: add files & commit• $ git status• # On branch master• # Untracked files:• # (use "git add <file>..." to include in what will be committed)• #• # .gitignore• # Gemfile• # Gemfile.lock• …….• nothing added to commit but untracked files present (use "git add" to track)
  18. 18. Git :: add files & commit• $ git add .• git commit - m ’Initial rails project’
  19. 19. Rails :: start server• rails s• => Booting WEBrick• => Rails 3.2.8 application starting in development on http://0.0.0.0:3000• => Call with -d to detach• => Ctrl-C to shutdown server• [2012-09-23 19:46:46] INFO WEBrick 1.3.1• [2012-09-23 19:46:46] INFO ruby 1.9.2 (2011-07-09) [x86_64-darwin11.2.0]• [2012-09-23 19:46:46] INFO WEBrick::HTTPServer#start: pid=32565 port=3000
  20. 20. Rails :: http://localhost:3000
  21. 21. Rails :: if rails server failed• If failed with:• home/pavelt/.rvm/gems/ruby-1.9.3-p194/gems/execjs- 1.4.0/lib/execjs/runtimes.rb:51:in `autodetect: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)• Uncomment therubyracer gem in ./Gemfile• bundle install• git add Gemfile*• git commit -m ‘Added gem therubyracer’
  22. 22. Heroku• What is Heroku?• Heroku is a cloud application platform – a new way of building and deploying web apps. (Heroku | About)• Heroku is a cloud platform as a service (PaaS) supporting several programming languages. (Wikipedia)• Heroku = Easy deployment• Heroku = No server managing• Heroku = Scale with 1 command• Heroku = Read-only file system
  23. 23. Heroku :: deployment• How to deploy to Heroku?• Simply push to master branch of your Heroku git repo• $ git push heroku master
  24. 24. Heroku :: install & configure• $ gem install heroku• Register at Heroku sign up page• https://api.heroku.com/signup• $ heroku login• Enter your Heroku credentials.• Email: paveltyk@gmail.com• Password (typing will be hidden):• Authentication successful.• More info: https://toolbelt.heroku.com
  25. 25. Heroku :: first app• $ heroku create pavelt-first-app• Creating pavelt-first-app... done, stack is cedar• http://pavelt-first-app.herokuapp.com/ | git@heroku.com:pavelt- first-app.git• Git remote heroku added• $ git remote -v• heroku git@heroku.com:pavelt-first-app.git (fetch)• heroku git@heroku.com:pavelt-first-app.git (push)
  26. 26. Heroku :: first app• Go to http://pavelt-first-app.herokuapp.com
  27. 27. Heroku :: first app• $ git push heroku master• The authenticity of host heroku.com (50.19.85.156) cant 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,50.19.85.156 (RSA) to the list of known hosts.• Permission denied (publickey).• fatal: The remote end hung up unexpectedly
  28. 28. Heroku :: first app• $ heroku keys:add• Could not find an existing public key.• Would you like to generate one? [Yn] y• Generating new SSH public key.• Uploading SSH public key /home/pavelt/.ssh/id_rsa.pub... done• $ git push heroku master
  29. 29. Heroku :: first app• Counting objects: 73, done.• Compressing objects: 100% (58/58), done.• ….• -----> Heroku receiving push• -----> Ruby/Rails app detected• -----> Installing dependencies using Bundler version 1.2.0• …• Installing sqlite3 (1.3.6) with native extensions• Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.• Failed to install gems via Bundler.• Detected sqlite3 gem which is not supported on Heroku.• http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development• Heroku push rejected, failed to compile Ruby/rails app
  30. 30. Heroku :: first app• Remove `gem ‘sqlite3’` line from ./Gemfile, update bundle and commit• $ bundle install• git commit -am ‘Removed SQLite3 gem’• $ git push heroku master• Counting objects: 73, done.• ….• -----> Heroku receiving push• -----> Ruby/Rails app detected• -----> Installing dependencies using Bundler version 1.2.0• …• Your bundle is complete! It was installed into ./vendor/bundle• …• -----> Writing config/database.yml to read from DATABASE_URL• -----> Preparing app for Rails asset pipeline• -----> Launching... done, v7• http://pavelt-first-app.herokuapp.com deployed to Heroku
  31. 31. Heroku• Q&A?
  32. 32. Tips & Tricks :: .rvmrc• Automatically change Ruby version and Gemset• ./.rvmrc• rvm use 1.9.3@first-app --create
  33. 33. Tips & Tricks :: disable Ri & RDoc• How to disable Ri and Rdoc?• ~/.gemrc• install: --no-ri --no-rdoc• update: --no-ri --no-rdoc
  34. 34. Tips & Tricks :: informative prompt• How to make prompt more informative?• ~/.bashrc• export GIT_PS1_SHOWDIRTYSTATE=true• export GIT_PS1_SHOWUNTRACKEDFILES=true• export GIT_PS1_SHOWSTASHSTATE=true• PS1=[$(~/.rvm/bin/rvm-prompt)]u:W[$(__git_ps1 "%s")]

×