Translate

January 14, 2014

Difference between Argument and Parameter in ruby on rails?

A parameter represents a value that the method expects you to pass when you call it.
An argument represents the value you pass to a method parameter when you call the method. The calling code supplies the arguments when it calls the method.

In simple words, parameters appear in method definitions; arguments appear in method calls.

For example, in below method, variables param1 and param2 are the parameters

def foo_method(param1, param2):
    .......
end

while calling the method, arg1 and arg2 are the arguments
 
foo_method(arg1, arg2)

January 9, 2014

What are filters? and how many types of filters are there in ruby?

Filters are methods that are run before, after or "around" a controller action.

Filters are inherited, so if you set a filter on ApplicationController, it will be run on every controller in your application.

Filter can take one of three forms: method reference (symbol), external class, or inline method (proc).

          after_filter
    append_after_filter
    append_around_filter
    append_before_filter
    around_filter
    before_filter
    filter_chain
    prepend_after_filter
    prepend_around_filter
    prepend_before_filter
    skip_after_filter
    skip_before_filter
    skip_filter