Select Filter doesn't work on static valued /non Mongoid field #53

Closed
jigyasam opened this Issue Sep 18, 2013 · 1 comment

Comments

Projects
None yet
3 participants

I'm trying to add a drop down filter on a custom field with static values.

filter :operation, :as => :select, :collection => ["min", "max"]

Here, 'operation' is not a 'field' in my registered Mongoid model.

I get an error with the following stack trace:

ActionView::Template::Error (undefined method `operation_eq' for #MetaSearch::Searches::MongoidSearchBuilder:0x007f8f7be2a420):
1: insert_tag renderer_for(:index)

I'm on latest master branch of this repo. I guess MetaSearch creates the dynamic '_eq' methods only on Mongoid fields. When I try a 'select' on a model field, it works well. This used to work on mongoid 2.x. Any pointers on how to fix it?

I had a very similar issue with a completely different gem, and ended up (after a number of hours of investigating ways to override the setter/getters) instanciating each custom field (as I was accessing the new action in the users controller, I added the following to users#new), from an array of custom fields. i.e.

GET /users/new

def new
@user = User.new

# Instanciate all dynamic fields, just in case!
dynamicFieldList = User.get_custom_fields

dynamicFieldList.each do |customField|
  @user[customField] = ""
end

end

If you have issues retrieving a list/array of dynamic/custom fields, try this:
http://stackoverflow.com/questions/11319867/list-dynamic-attributes-in-a-mongoid-model/29132027#29132027

@boie0025 boie0025 closed this Jun 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment