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
- Ruby on Rails Guides
- RailsCasts
- Rails for Zombies
- Rails for Zombies 2
- Rails Best Practices
- Testing with RSpec
- PeepCode
- Ruby on Rails Tutorial