Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby on Rails, Up and Running

Ruby on Rails, Up and Running

Presentation for Gristmill's Ruby on Rails, Up and Running class.

tristanoneil

May 31, 2012
Tweet

More Decks by tristanoneil

Other Decks in Technology

Transcript

  1. “Ruby on Rails is astounding. Using it is like watching

    a kung-fu movie, where a dozen bad-ass frameworks prepare to beat up the little newcomer only to be handed their asses in a variety of imaginative ways.” Nathan Torkington, O’Reilly Media
  2. id title body 1 a blog post part I lorem

    ipsum... 2 a blog post part II lorem ipsum... 3 a blog post part III lorem ipsum... Active Record Database tables map to Ruby objects and columns become instance variables with getter and setter methods. class Post < ActiveRecord::Base end @post = Post.find(1) puts @post.title a blog post part I posts table
  3. Action View Handles template rendering. Can use various template languages

    but Rails comes standard with ERB which is just Ruby mixed into HTML. <ul> <% @posts.each do |post| %> <li><%= post.title %></li> <% end %> </ul> • a blog post part I • a blog post part II • a blog post part III posts.html.erb as seen in the browser
  4. Action Controller Made up of various actions that are executed

    upon a request. Responsible for responding or directing web requests through an application. Typically requests data from a model and responds with a view. class PostsController < ApplicationController def index @posts = Post.all end end Gets all posts and renders the posts/index.html.erb view. How does it know?!
  5. REST Convention for working with resources over HTTP. GET PUT

    POST DELETE GET /posts => Returns all posts, usually maps to an index action GET /posts/123, usually maps to a show action => Returns a post with the ID of 123
  6. Ruby Gem A packaged Ruby library or application. You can

    install Ruby Gems using the RubyGems CLI tool like or you may use... gem install rails
  7. Rake Command line tool to script common tasks. For instance,

    migrating the database or running an application’s test suite. rake db:migrate rake test:unit
  8. RVM Ruby Version Manager allows you to easily install, manage,

    and work with multiple ruby environments. Not necessary but very handy.
  9. Git Has nothing to do with Ruby per se, but

    it is the de facto tool used to keep track of code. Git is a distributed version control system.