Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

jigyasam opened this issue Sep 18, 2013 · 1 comment
Labels

Comments

@jigyasam
Copy link

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?

@xtrasimplicity
Copy link

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 as completed Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants