Slide 1

Slide 1 text

GETTING STARTED WITH RUBY ON RAILS

Slide 2

Slide 2 text

@rebagliatte Vero Rebagliatte

Slide 3

Slide 3 text

Forecast 1. What’s ROR? 2. The rails way 3. Example app

Slide 4

Slide 4 text

What’s ROR?

Slide 5

Slide 5 text

It’s a framework

Slide 6

Slide 6 text

Was created by DHH

Slide 7

Slide 7 text

Lowers the barrier to start programming in Ruby

Slide 8

Slide 8 text

Opinionated

Slide 9

Slide 9 text

The Rails Way

Slide 10

Slide 10 text

Be DRY, don’t repeat yourself

Slide 11

Slide 11 text

Prefer convention over configuration

Slide 12

Slide 12 text

Be RESTful

Slide 13

Slide 13 text

REST uses operations of the HTTP protocol

Slide 14

Slide 14 text

REST GET PUT POST PATCH DELETE SOAP getUsers() getNewUsersSince() savePurchaseOrder() getUser() addUser() removeUser() updateUser() getLocation()

Slide 15

Slide 15 text

REST uses resources

Slide 16

Slide 16 text

http://myblog.com/posts/ GET PUT POST DELETE http://myblog.com/posts/1 GET PUT POST DELETE } }

Slide 17

Slide 17 text

Blog::Application.routes.draw do resources :posts end config/routes.rb

Slide 18

Slide 18 text

Use the MVC (Model View Controller) Pattern

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

class Post < ActiveRecord::Base attr_accessible :content, :name, :title has_many :commenters validates :title, presence: true end app/models/post.rb

Slide 21

Slide 21 text

Post <%= @post.title %>

<%= @post.content %> <%= link_to 'Edit', edit_post_path(@post) %> <%= link_to 'Back', posts_path %> app/views/posts/show.rb

Slide 22

Slide 22 text

class PostsController < ApplicationController def new @post = Post.new end def create @post = Post.new(params[:post]) if @post.save redirect_to @post, notice: 'Post created!' else render action: :new end end end app/controllers/posts_controller.rb

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Package your code for reuse

Slide 25

Slide 25 text

source 'https://rubygems.org' gem 'rails', '3.2.13' gem 'sqlite3' group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' Gemfile

Slide 26

Slide 26 text

Be fast by default with the Asset Pipeline

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

app/assets assets from the current application lib/assets your own libraries, shared across applications vendor/assets third party assets(js plugins, css frameworks)

Slide 29

Slide 29 text

PRECOMPILE

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

CONCATENATE

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

application.css application.js logo.jpg application-908e25f4bf641 868d8683022a5b62f54.css application-908e25f4bf641 868d8683022a5b62f54.js logo-908e25f4bf641868d8 683022a5b62f54.jpg ADD MD5 FINGERPRINT

Slide 34

Slide 34 text

COMPRESS

Slide 35

Slide 35 text

More

Slide 36

Slide 36 text

Internationalize your app

Slide 37

Slide 37 text

Use generators

Slide 38

Slide 38 text

Example App

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

Thanks! @rebagliatte