ransack

Check boxes search with Ransack gem

情到浓时终转凉″ 提交于 2020-06-09 11:39:51
问题 I need to filter data in a table. To do this, I found meta_search gem. I installed meta_search and I get this error: uninitialized constantActiveRecord::Associations::ClassMethods::JoinDependency This is deprecated for Rails 4 (framework that I'm using). So, I installed ransack (rails 4 branch) (gem based on meta_search) and works beautifully. The problem is that I need to use the meta_search's collection_checks method to handle check boxes and this method does not exist in ransack. So, the

Check boxes search with Ransack gem

一个人想着一个人 提交于 2020-06-09 11:39:10
问题 I need to filter data in a table. To do this, I found meta_search gem. I installed meta_search and I get this error: uninitialized constantActiveRecord::Associations::ClassMethods::JoinDependency This is deprecated for Rails 4 (framework that I'm using). So, I installed ransack (rails 4 branch) (gem based on meta_search) and works beautifully. The problem is that I need to use the meta_search's collection_checks method to handle check boxes and this method does not exist in ransack. So, the

ransack search form in header partial: No Ransack::Search object was provided to search_form_for

為{幸葍}努か 提交于 2020-02-26 07:33:04
问题 First of all, I'm new to RoR, so the answer may be obvious, in which case I apologize. I've looked around and haven't found anything that helps. I'm trying to have a search form at the header of every web page on my app that will search through the names of all my "buckets". Here is the relevant code: In app/views/layouts/_header.html.erb (within a nav bar): <% search_form_for @q do |f| %> <%= f.label :name_cont %> <%= f.text_field :name_cont %> <%= f.submit %> <% end %> In app/controllers

How build a advanced search with checkbox using Ransack?

為{幸葍}努か 提交于 2020-01-17 07:32:46
问题 how I build a advanced search how this image: I have my controller, very basic yet: def index @q = Product.ransack(params[:q]) @products = @q.result(distinct: true) end And have my view: <%= search_form_for @q do |f| %> <%= f.label :name_cont, "Name" %> <br /> <%= f.search_field :name_cont %> <br /> <%= f.label :brand, "Brand" %> <br /> <%= f.collection_check_boxes :brand, Product.all, :id, :brand %> <br /> <%= f.label :hd, "HD" %> <br /> <%= f.collection_check_boxes :hd, Product.all, :id,

Ransack: how to merge sub-queries?

岁酱吖の 提交于 2020-01-17 02:21:10
问题 I need to filter according to key + value in a polymorphic association. In this example, an Incident can have many CustomFieldsValues , and I need to filter Incidents by CustomFieldsValue.custom_field_id and CustomFieldsValue.value . I tried creating a search like the following SQL query: SELECT id FROM incidents WHERE id IN ( SELECT customfieldable_id from custom_fields_values WHERE (custom_fields_values.custom_field_id = 1091 AND (custom_fields_values.value >= '2015-06-29 10:00:00') AND

How to use Ransack in navbar search form?

二次信任 提交于 2020-01-15 11:07:08
问题 I am using Ransack with Rails 5 to search images in gallery by their descriptions. Search form is located in navbar, and Ransack gives me results only when I'm displaying images gallery page. Searching don't return any result when I display any other pages including the same navbar. My code from _header.html.erb: <div class="form-group"> <%= search_form_for @q, url: search_pins_path, html: { method: :post } do |f| %> <%= f.search_field :description_cont, type: "text", class: "form-control",

How to use Ransack in navbar search form?

£可爱£侵袭症+ 提交于 2020-01-15 11:07:07
问题 I am using Ransack with Rails 5 to search images in gallery by their descriptions. Search form is located in navbar, and Ransack gives me results only when I'm displaying images gallery page. Searching don't return any result when I display any other pages including the same navbar. My code from _header.html.erb: <div class="form-group"> <%= search_form_for @q, url: search_pins_path, html: { method: :post } do |f| %> <%= f.search_field :description_cont, type: "text", class: "form-control",