the readme of searchlogic

Before I use a library in my application I like to glance at the source and try to at least understand the basics of how it works. If you are like me, a nice little explanation from the author is always helpful:

Searchlogic utilizes method_missing to create all of these named scopes. When it hits method_missing it creates a named scope to ensure it will never hit method missing for that named scope again. Sort of a caching mechanism. It works in the same fashion as ActiveRecord's "find_by_*" methods. This way only the named scopes you need are created and nothing more.

The search object is just a proxy to your model that only delegates calls that map to named scopes and nothing more. This is obviously done for security reasons. It also helps make form integration easier, by type casting values, and playing nice with form_for. This class is pretty simple as well.

That's about it, the named scope options are pretty bare bones and created just like you would manually.

 

Searchlogic利用method_missing的创建这些命名范围的。当它攻击的method_missing它创建一个命名范围,以确保它永远不会达到方法命名范围的method messing。这样的缓存机制。该工程作为的ActiveRecord的“find_by_ *”方法相同的方式。只有这样命名的范围你需要的是创造,仅此而已。

你可能感兴趣的:(Security,Ruby,ActiveRecord,Rails)