Обзор Ruby on Rails

 Нистратов Артём

anistratov@go-promo.ru

  • RVM
  • Ruby
  • Gem
  • Bundler
  • Rails
  • Git

RVM

Ruby Version Manager

rvm install 2.1
rvm use 2.1
rvm list

Ruby

2.1.3 :001 > 1 + 2
 => 3

2.1.3 :002 > puts 'Hello world!'
Hello world!
 => nil

2.1.3 :003 > 'Hello'.sub(/[l]+/, 'r').downcase.reverse.chars
 => ["o", "r", "e", "h"]
ruby -v
irb

GEM

 

Package Manager

  • Repository
  • Storage
  • CLI
gem install rails --no-ri --no-rdoc
  • GitHub
  • RubyGems
  • gem

Rails

rails new first_project
.
├── Gemfile
├── Gemfile.lock
├── Rakefile
├── app
|   ├── assets
|   ├── controllers
|   ├── helpers
|   ├── mailers
|   ├── models
|   └── views
├── bin
├── config
├── db
├── lib
├── log
├── public
├── test
├── tmp
└── vendor
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby
bundle install
rake db:create

Bundler

Dependency Resolver

Bundler обеспечивает согласованную среду для проектов на Ruby, отслеживая и устанавливая  только те версии пакетов, которые необходимы.

ruby '2.1.2'
source 'https://rubygems.org'

gem 'rails', '~> 3.2.21'

gem 'migration_comments'

gem 'activerecord-mysql-unsigned'

Git

Version Control System

git status
git add ./
git commit -m "Initial commit"

Git Workflow

first

By adone

first

  • 856