ransack

using autocomplete in app with ransack

Deadly 提交于 2019-12-25 01:48:17
问题 Good day. I hame a controller that uses ransack to find articles by their title. I need field that's used for finding info to use autocomplete. Currently it finds alright, but no autocomplete, could you assist me in that problem and gem https://github.com/crowdint/rails3-jquery-autocomplete-app? Gemfile gem "ransack" gem 'rails3-jquery-autocomplete' gem 'nifty-generators' gem 'jquery-rails', '~> 2.0' in view: <%= search_form_for @q do |f| %> <%= f.label t('.find') %> <%= f.autocomplete_field

Ransack and namespaced routes… Template missing

亡梦爱人 提交于 2019-12-24 17:34:11
问题 When I search anything I always have the error : Missing template backstage/users/search, application/search with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "C:/RailsApps/novaxones/app/views" I have a User model in app/models class User < ActiveRecord::Base attr_accessible :email, :password, :password_confirmation, :remember_me, :created_by, :active, :blocked, :profile_attributes has_secure_password # relations has_one :profile, :dependent =>

Ransack search for integer and string values from single search field

我是研究僧i 提交于 2019-12-24 04:26:14
问题 I am using Rails 4 with Ransack. I cant make to work searching for integer and string values. So far I tried this code. In view: <%= search_form_for @search do |f| %> <div class="field"> <%= f.label :name_cont, "Nepieciešama meklēšāna pēc ID, vārda un telefona nr" %> <%= f.text_field :name_or_phone_number_cont_or_id_eq, :placeholder => 'Meklēt pēc ID,vārda vai tel.nr.' %> </div> <div class="actions"><%= f.submit "Search" %></div> <% end %> In controller : def index @search = Advertisement

Ransack search on data stored in array (operator does not exist: integer[] = integer)

可紊 提交于 2019-12-24 01:39:26
问题 I have a Rails model call InfoData and it has an attribute called error_codes. The codes are stored in an array like so [9,7,10,21] (integer[]) . To recap InfoData.first.error_codes => [9,7,5] I try to use ransack on it in order to search if a specific code is present(via a select option). For error_codes_in (_in ransack predicate) I receive the following error operator does not exist: integer[] = integer LINE 1: ...ranch_id" WHERE "info_data"."error_codes" IN (9) A... ^ HINT: No operator

ActiveAdmin: Filter by count of child objects

天大地大妈咪最大 提交于 2019-12-23 22:32:28
问题 In a Ruby on Rails app that heavily relies on ActiveAdmin, I have a Sponsor model, which is associated with a Sponsorship model. One sponsor can sponsor many children, so one sponsor can have many sponsorships . What I would like to do, is to be able, on the Sponsor index page, to filter out sponsors by the number of sponsorships they have. So that, for example, I want to see only those sponsors who have more than one sponsorship, or less than five, and so on. You get the idea. In Ruby-speak,

How to configure Ransack Rails Gem to add NULLS LAST to sort

懵懂的女人 提交于 2019-12-23 12:19:30
问题 I would like Ransack to always add NULLS LAST which will put nulls last for the sort column. Any way to do this? I opened a github issue on this one: https://github.com/activerecord-hackery/ransack/issues/443 回答1: The answer is found in the thread linked in the question above. Writing it here so its easier to find. Apparently you need to build the order string again and add Null Last to it. This solved it for me (works on all columns): @q.result.except(:order).order("#{@q.sorts.first.name} #{

Howto set a default condition with fieldname on ransack?

送分小仙女□ 提交于 2019-12-23 12:18:50
问题 I have a user and a roles model, both are associated via habtm and there is a forum model associated to roles. In ransack search form for forums i want to filter by users who have a specific role (by name: moderator). Source looks like this: class User < ActiveRecord::Base has_and_belongs_to_many :roles, :join_table => :users_roles rolify class Role < ActiveRecord::Base has_and_belongs_to_many :users, :join_table => :users_roles belongs_to :resource, :polymorphic => true class Forum <

Ransack save search form value in advanced form search, save and edit these details

匆匆过客 提交于 2019-12-23 02:39:46
问题 I am developing an application for advanced search using ransack gem in ruby on rails. I am got stuck with the below problems How to save an form search value and save these details for later query Edit the saved query by generating an form by taking the existing query delete the query Please help me find the solution for this. 来源: https://stackoverflow.com/questions/47646796/ransack-save-search-form-value-in-advanced-form-search-save-and-edit-these-deta

Ransack: how to join table multiple times with different alias?

冷暖自知 提交于 2019-12-22 18:36:32
问题 Suppose I have :items with a has_many association with :properties, then I can search for all items that have a property with name 'a_name' and value 'a_value' like this q: { properties_name_eq: 'a_name', properties_value_eq: 'a_value' } Now what if I want to search for all items that have a property with name 'a_name' and value 'a_value' and also a property with name 'another_name' and value 'another_value'? The following doesn't work as it joins the properties table only once q: { g: { '0'

eq_any for boolean attributes - ransack

半腔热情 提交于 2019-12-22 05:39:33
问题 I have a boolean attribute (published) in my model book and I wish to filter all books using checkboxes on that value. class Book < ActiveRecord::Base attr_accessible :published end That means I'd like something like eq_any but for true or false . Is there a way to do this using Ransack? UPDATE I'd like users to be able to select only published books, only unpublished books and any book. So a single checkbox won't do. 回答1: I have solved this by using a select list with three options: "All",