Getting Started with Ruby on Rails

6bbed4d8a26da005cfd4e9e179d50c9d?s=47 Vero Rebagliatte
June 12, 2013
110

Getting Started with Ruby on Rails

6bbed4d8a26da005cfd4e9e179d50c9d?s=128

Vero Rebagliatte

June 12, 2013
Tweet

Transcript

  1. GETTING STARTED WITH RUBY ON RAILS

  2. @rebagliatte Vero Rebagliatte

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

    app
  4. What’s ROR?

  5. It’s a framework

  6. Was created by DHH

  7. Lowers the barrier to start programming in Ruby

  8. Opinionated

  9. The Rails Way

  10. Be DRY, don’t repeat yourself

  11. Prefer convention over configuration

  12. Be RESTful

  13. REST uses operations of the HTTP protocol

  14. REST GET PUT POST PATCH DELETE SOAP getUsers() getNewUsersSince() savePurchaseOrder()

    getUser() addUser() removeUser() updateUser() getLocation()
  15. REST uses resources

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

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

  18. Use the MVC (Model View Controller) Pattern

  19. None
  20. class Post < ActiveRecord::Base attr_accessible :content, :name, :title has_many :commenters

    validates :title, presence: true end app/models/post.rb
  21. <h1>Post <%= @post.title %> </h1> <%= @post.content %> <%= link_to

    'Edit', edit_post_path(@post) %> <%= link_to 'Back', posts_path %> app/views/posts/show.rb
  22. 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
  23. None
  24. Package your code for reuse

  25. 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
  26. Be fast by default with the Asset Pipeline

  27. None
  28. app/assets assets from the current application lib/assets your own libraries,

    shared across applications vendor/assets third party assets(js plugins, css frameworks)
  29. PRECOMPILE

  30. None
  31. CONCATENATE

  32. None
  33. application.css application.js logo.jpg application-908e25f4bf641 868d8683022a5b62f54.css application-908e25f4bf641 868d8683022a5b62f54.js logo-908e25f4bf641868d8 683022a5b62f54.jpg ADD

    MD5 FINGERPRINT
  34. COMPRESS

  35. More

  36. Internationalize your app

  37. Use generators

  38. Example App

  39. None
  40. Thanks! @rebagliatte