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".)