Ruby on Rails: Convensions over Configurations
- Jagadish. M
The interest of developer will always be towards learning new technologies. It’s secondary that whether in real-time you are going to use it in or not. One of the most popular and fastest growing technologies that I came across is Ruby on Rails (RoR).
Ruby on Rails was developed by David Heinemeier Hansson from his work on BaseCamp; a project management tool, which offers to-do lists, wiki-style web-based text documents, milestone management, file sharing, time tracking, and a messaging system.
Like many web frameworks, Rails uses the Model View Controller (MVC) architecture to organize applications.
Features of Ruby:- Each and Everything is Object: Even numbers in ruby are treated as object. Looking at the example, what output you can expect from this?
8.times {print “Guess what”} its prints Guess what 8 times.
- Powerful blocks: Code blocks can be passed as parameter to method. Following example prints out all the elements in an array
jArray.each{|element| print element}
- Return is optional in Methods: In ruby return statement is optional in methods. The value of the last expression becomes the return value of that method. For example:
def testReturn n = 2 * 3 en
- Parallel Assignment in Ruby: We can change the multiple variables in one assignment statement. Swapping of two variables is the good example for it. n1 = 1
n2 = 3
n1, n2 = n2,n1
- Everything in Ruby is open: Including the built-in classes, in ruby, additional methods can be added to the classes even at run-time also. For example: FixNum is the build in Data Type for all to which I added the method called old.
class Fixnum
def old return self-1
endend
8.old # prints 7
(The author, Jagadish.M, is a Software Engineer at Binary Spectrum).
- Parallel Assignment in Ruby: We can change the multiple variables in one assignment statement. Swapping of two variables is the good example for it. n1 = 1