Posted by Kresimir Bojcic on May 29, 2009
The best tutorial about auto complete control by far was one from Ryan Bates. It worked like a charm, and he made it look so easy. Only problem I had with it was that I wanted another control on the form to filter the auto-complete control.
The tutorial didn’t cover that, so I got stranded in a strange place. The solution was pretty simple, but it took me a while to figure it out. If you are just beginning Rails like I am – this is rigth tutorial for you.
(more…)
Posted by Kresimir Bojcic on May 16, 2009
Block is basically anonymous method that gets called from another method. If you have some code that executes passed in method like this:
def execute_method_in_block(named_method)
named_method.call
named_method.call
end
execute_method_in_block Proc.new {puts "Hello, blocks are cool!"}
You can write it like this using blocks:
def execute_method_in_block
yield
yield
end
execute_method_in_block {puts "Hello, blocks are cool!"}
We’ve lost “Proc.new” and a method name, we are just saying
Whenever you find yield, execute block that is defined within braces.
You might be wondering what’s the fuss all about, (more…)