Ruby on Rails
Ruby on Rails
Ruby on Rails is a dynamic open source, pure object-oriented programming language that focuses on simplicity and productivity. Everything in Ruby is an object. It also has a natural to read and easy to write elegant syntax.
I’m learning Ruby on Rails through an online course at UDEMY, taught by Mashrur Hossain and Rob Percival. I will be taking notes and posting my work here, so that I can remember them later. It’s a fairly big course (48hrs), so I expect to be working on it on my off time for the next 2-3 months. Examples and resources for Ruby on Rails can be found below.

My Ruby on Rails Examples
- Introduction Hello World
- Working with Strings
- Getting Inputs from User
- Working with Numbers
- Brief Look at Comparison Operators
- Methods
- Branching if/elsif/else/end
- Arrays and Iterators
- Hashes aka Dictionary
- Ruby Style Guide
- Introduction to Object Oriented Programming
- Attributes, Getters, and Setters
- Classes, Modules, and Mixins
Projects
- Authenticator Project : This is a simple example of a login authenticator
- Area Code Dictionary Project : This gives the area code for each city.
- Text-Follow-Up:
Resources
- https://www.ruby-lang.org/en/ Official Ruby Language site
- RubyonRails Official site and guides
- RubyGems.org Find, install, and Publish RubyGems
- Guides.RubyGems examples on how to use the RubyGems
- Repl.it Online coding platfrom, over 50 languages, good for Ruby on Rails
- Github.com Where I save my public projects. Find Gems here too.
- BitBucket.org Where I save my private projects. Find Gems here too.
- RVM.io Ruby Version Manager
- VirtualBox.com Download VirtualBox
- Ubuntu.com Best linux platform
- Ruby Style Guide Best practices and examples for styling Ruby Code
- TryRuby Online ~30minute playground to learn Ruby
Gems
- bcrypt – An easy way to keep your users’ passwords secure
Quick Notes
String concat structure:
String1 + ” ” + String2 + String3
Some methods that can be used on objects:
objectname.nil?
objectname.empty?
objectname.length
objectname.reverse
To escape the evaluation of #{variablename} within a String, prepend with \:
\#{variablename}
To get input from the command line and assign it to a variable
variablename = gets.chomp
Command Line Shortcuts
pwd (present working directory)
cd (change directory)
(tab) (use tab to autotype and fill in names)
cd (tab) (shows any thing available in directory)
cd ~/(tab) (brings up all available directories, use tab again to autocomplete a directory name)
mkdir (make directory)
ls (to see files in a directory)
../ (back/up one directory)
clear (clears screen)
irb (Interactive Ruby, it’s the run command to start a console)
exit (to exit the console)
ctrl-l (clear the screen, Note: does not work in Replit.com)
.class (suffix to find what class the object belongs to:. ex: string, integer, etc…)
.methods (suffix to pull up all the methods available to an object: )
Comparison Operators
Operator | Name | Example | Result |
---|---|---|---|
== | Equal | x==y | True if x is exactly equal to y. |
!= | Not equal | x!=y | True if x is exactly not equal to y. |
> | Greater than | x>y | True if x is greater than y. |
< | Less than | x<y | True if x is less than y. |
>= | Greater than or equal to | x>=y | True if x is greater than or equal to y. |
<= | Less than or equal to | x<=y | True if x is less than or equal to y. |
<=> | Combined comparison operator. | x<=>y | x <=> y : = if x < y then return -1 if x =y then return 0 if x > y then return 1 if x and y are not comparable then return nil |
=== | Test equality | x===y | (10…20) === 9 return false. |
.eql? | True if two values are equal and of the same type | x.eql? y | 1 == 1.0 #=> true 1.eql? 1.0 #=> false |
equal? | True if two things are same object. | obj1.equal?obj2 | val = 10 => 10 val.equal?(10) => true |