0

I have two Rails sites, Bargain Stock Funds (http://www.bargainstockfunds.com) and Doppler Value Investing (http://www.dopplervalueinvesting.com).

Bargain Stock Funds now has a search feature that allows users to obtain a list of funds meeting certain criteria. (The URL is http://www.bargainstockfunds.com/funds .) Doppler Value Investing also has a search feature that allows users to obtain a list of stocks meeting certain criteria. (The URL is http://www.dopplervalueinvesting.com/stocks/ .) Both sites use the Ransack gem to provide the search feature and the Kaminari gem to paginate the results.

Is there a way I can configure the search engines so that they are pre-loaded with certain criteria already set? For Bargain Stock Funds, I want the search engine pre-configured to exclude funds with a load_front or load_back value greater than 0.0%, and I want the results sorted with respect to the value of the pcf parameter. For Doppler Value Investing, I want the search engine pre-configured to exclude funds with a pass_legit value of false or a pass_quality value of false, and I want the results sorted with respect to the value of the dopeler_pb parameter. These pre-configured settings would save the user the trouble of having to hunt around for the criteria in the drop-down menus.

The source code for the search form for Bargain Stock Funds is:

<%= search_form_for @search, url: search_funds_path, method: :post do |f| %>
  <%= f.condition_fields do |c| %>
    <%= render "condition_fields", f: c %>
  <% end %>
  <p><%= link_to_add_fields "Add Conditions", f, :condition %></p>
  <div class="field">
    Sort:
    <%= f.sort_fields do |s| %>
      <%= s.sort_select %>
    <% end %>
  </div>
  <div class="actions"><%= f.submit "Search" %></div>
<% end %>

The source code for the search form for Doppler Value Investing is quite similar. (Just replace "funds" with "stocks".)

4

1 回答 1

0

不确定我是否完全遵循。您所说的“搜索引擎”是指谷歌吗?或者您的意思是您的应用程序搜索逻辑?

如果是后者,这可能会有所帮助: https ://stackoverflow.com/a/14553363/1797331

我得去看看你的网站。我正在开发类似的东西,专注于股票基本面——但最近没有做太多。你可能会激励我。

于 2013-12-02T02:23:33.787 回答