Saturday, March 10, 2012

Interview Question : Named Scope

Question : What is named_scope?

Well, just as a info, previously it was Nick Kallen’s a very popular plugin has_finder. This turned out a better alternative for excellent plugins like scope_out and scope_proxy.
For more information about has_finder go through Nick Kallen's post HasFinder -- It's Now Easier than ever to create complex, re-usable SQL queries.
Later it was merged with rails and named as named_scope and now just scope in rails 3.

Well, Named scopes are finder methods provided by rails which helps us to build custom queries. The biggest advantage of named scopes is, that these can be chained up together.

The best article on this is Ryan's Scraps : Named Scope: It's Not Just for Conditions, Ya Know?.

No comments:

Post a Comment