Updated this post as per post recommendations:
Inconsistent naming conventions in rails is confusing the heck out of me. IT SEEMS LIKE THE SYNTAX IS ALL OVER THE PLACE IN RAILS…
Here are some examples:
Why are there commas in the migration below ? And why is keyword “default” not with a colon before it? What is this default keyword? a method, or a variable, a symbol.. What is that darn thing??:
add_column :zombies, :rotting, :boolean, default: false
Here is another example:
Why age not :age (with a colon)? WHY IS make_rotting CALLED WITH A ” : ” BEFORE IT??
class Zombie < ActiveRecord::Base
before_save :make_rotting
def make_rotting
if age > 20
self.rotting = true
end
end
end
I am a Java guy, yes java is verbose but at-least its consistent I feel like going back 🙁
first of all there are different type of variable:
1.Local variable
2.Instance variable
3.Class variable
4.Global variable
You can simply differentiate among them by the way they are used.
Now if talk about property of a model,can declare as
Now
validateandvalidatesboth are differentwhere
validatesis use to validate properties.where
validateis to validate some method