Anu
Joined: 01 Jan 2010 Posts: 80
|
Posted: Fri Feb 05, 2010 5:48 am Post subject: About Filters |
|
|
Filters enable controllers to run shared -pre and post- procedures,fot its actions.
There are so many filters in rails,letus know some of them below:
+Skip_filter
+After_filter
+Before_filter
*Skip_filter:
1)This skip_filter Removes the specified filters from the filter chain.
2)This method is different from skip_after_filter and skip_before_filter in that it will match any before, after filter.
3)You can control the actions to skip the filter for with the :only and :except options, just like when you apply the filters.
Example:
class BankController < ActionController::Base
skip_filter:catch_exceptions
end
*Before_filter:
1)The passed filters will be appended to the filter_chain and will execute before the action on this controller is performed.
Example:
class BankController < ActionController::Base
before_filter :audit
end
*After_filter:
1)The passed filters that run after actions on this controller are performed.
Example:
class BankController < ActionController::Base
after_filter:catch_exceptions
end
Diffrences in between these filters:
*The skip_filter,before_filter,after_filter are those which are completly diffrent in showing their functionality.
*Before_filter is what execute before the action got performed,whereas after_filter is quite apposite for this,execute after the action perfomed.
*And as well as skip_filter removes the specified filter from the filter chain.
Thanks & Regards,
Anasuya.N. |
|