开发者

Inspect MetaSearch columns

开发者 https://www.devze.com 2023-02-18 08:32 出处:网络
Regarding MetaSearch, I would like to extract \"human\" names from the search parameters.For example, when the params[:search] has non-blank values for the following:

Regarding MetaSearch, I would like to extract "human" names from the search parameters. For example, when the params[:search] has non-blank values for the following:

- title_contains

- author_name_contains

I would like to extract:

- title

- author name

The end use would be to provide additional feedback to the user such as:

Results filtered on title and author name

I would like to use functions within the MetaSearch library t开发者_开发百科o achieve this instead of re-developing the param parsing. While the above examples are simple in Ruby the MetaSearch parameter language can be expressive.

Thanks


If you really want to get these from the MetaSearch object, you can do something like:

@search.search_attributes.except('meta_sort').select {|k, v| v.present?}

I'm not really sure that you're gaining anything over pulling this from the params directly, though. In any real-world usage, you'd probably want to change the text you display based on the predicate.

You may want to tackle this using i18n, instead:

http://rdoc.info/github/ernie/meta_search/master/file/README.rdoc#Localization

0

精彩评论

暂无评论...
验证码 换一张
取 消