Skip to content

Instantly share code, notes, and snippets.

@spilth
Created September 18, 2012 22:53
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save spilth/3746532 to your computer and use it in GitHub Desktop.
Save spilth/3746532 to your computer and use it in GitHub Desktop.
Ruby on Rails Crash Course

Ruby on Rails Crash Course

This is a course meant to give you the basics of Ruby and Rails with the assumption that you'll use the resources provided below to further your learning.

It assumes you are familiar with basic programming concepts and the basics of object oriented programming.

Basics

Create a Ruby Script

Create a file named hello.rb

puts "Hello!"

Run a Ruby Script

$ ruby hello.rb

Start the Interactive Ruby Shell

$ irb
1.9.3-p194 :001 >

Define a Method

def hello
  puts "Hello!"
end

Call a Method

hello

Define a Method that takes an Argument

def hello(name)
  puts "Hello, #{name}!"
end

Call a Method with an Argument

hello("Brian")

Define a class

class Person

end

Instantiate a class

brian = Person.new

Define a Class Initializer

class Person
  def initialize
    puts "Initialize!"
  end
end

Define a Class Initializer with Arguments

class Person
  def initialize(name)
    puts "Initializing '#{name}'"
  end
end

Instantiate a class using an initializer

brian = Person.new("Brian")

Define an instance method

class Person
  def hello
    puts "Hello there!"
  end
end

Call an instance method

brian = Person.new("Brian")
brian.hello

Define an Instance Variable

Define Instance Variable Accessors

Using Arrays

Using Hashes

Intermediate

Extend a Class

class Employee < Person

end

Re-opening Classes

Define a Class Method

Call a Class Method

Blocks

Symbols

Define a Module

module Hello

end

Define a Module Method

module Hello
  def hello
    puts "Hello!"
  end
end

Call a Module Method

Hello::hello

Include a Module

include Hello

Include a module's methods in a class as instance methods

Include a module's methods in a class as class methods

Modules vs. Classes

Ruby Load Path

Require a Method or Class

Ruby Gems

Install a Gem

$ gem install pry

Ruby Version Manager

Install RVM

Install Ruby via RVM

Bundler

Install Bundler

Define a project's Gems

Install a projcet's Gems

Testing

RSpec

Libraries

Devise

Guard

Resources

Language, Gems & Tools

Documentation

Instructional Sites

Ruby

Rails

Books

@christianbundy
Copy link

Is this doc going to be updated any time soon? Great idea, but quite a few things missing. :(

@algal
Copy link

algal commented Oct 15, 2013

Would also love to see this completed.

Copy link

ghost commented Oct 1, 2016

I'd love to see this complete

@thewilliamzhang
Copy link

very neat tutorial lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment