[WIP] RoR: Getting started
C01ors
Few rules about RoR
1) DRY - Don't repeat yourself.
Imagine if every time a kid asked you, "are we there yet?" and you had to keep responding: "yes, yes, yes". Your doing the same thing over and over. Pretty annoying right? So the idea here is that if you're using something that is going to be used constantly, put the code in one place (organized! you will learn more about this in a bit)
2) KISS - Keep it simple stupid.
Simple to explain: take the long way home or the short way? Pretty easy to choose.
3) Organization - not only for your room.
Ruby On Rails is based on MVC, this stands for Model View Controller. Almost anything dealing with the database goes into the model. If you have a users table (everything is plural, they hold multiple rows) you would create a User.login(username,password) method, or a current_user.is_admin? function.
4) Ruby is simple & sexy
This is PHP:
function myFunction($a=1,$b=1){
return $a + $b;
}
This is Ruby
def myFunction(a=1,b=1) a+b end
instead of writing "function" we write "def" for define.
instead of using braces we write 'end'
the last of anything that returns something (such as an addition) automatically returns, but I could also write
return a+b;
or
if a == 0 return true elsif b == 0 return true end return "Nothing returned!"
As you may see, typing "return" ends the processing of the function (this is normal in any language).
Now for another big difference! To use this function in PHP you would need to write.
myFunction; myFunction(); myFunction(2,5);
But in ruby you can do the following
myFunction myFunction() myFunction 2, 5 myFunction(2,5) myFunction 2 , 5
Now that you have a general idea of what Ruby on Rails is about, this is probably the best way to learn it. But this is a free alternative.
Why aren't I posting my own 'get started'? Guess you didn't read #2 (noticed how I didn't say what it was






Cartoon Clouds
Mountains
Sunrise
Clouds
Green Clouds
None




















Help