|
|
|
|
|
by weaksauce
2093 days ago
|
|
the magic in rails is not really magic once you get used to the fact that all those magic incantations are just method calls inside the class. every class in ruby is just a series of method calls. you can write a class that, when it's read from the file and interpreted will just print something... class Foo puts "bar"
endwill just print `bar` when it's parsed. so something like has_many :baz are just the method call `has_many(:baz)` defined by active record. that creates a few functions using meta-programming. the other thing that ruby uses a lot of are blocks which are just anonymous functions. `do |a,b,c| puts a; end` just a function passed to the method that can be invoked by the function. I think those things are the ones that trip people up the most with when learning. |
|