Open killthekitten opened 12 years ago
Nobody experienced this issue?
This problem still exists, and I've been trying to find a way to work this out...
I can't reproduce this issue sine I closed it (I think it was 0.0.2 or 0.0.3). Can you describe your case in more details?
This might be related to my pull request #1630
I believe this still exists. Fintan explains the issues he is having here: https://groups.google.com/forum/#!msg/rails_admin/DZi4stvJyrM/zQOC9InjkisJ
I also have run into this. User roles are stored in my database as an integer, so I was using an enum to make editing a user more understandable:
def role_enum [['user',0], ['moderator',1], ['staff',2], ['admin',3]] end
However, having this in the code produces the error: invalid input syntax for integer: "string" ...ile_image_url) ILIKE '%string%') OR (users.role IN ('string')) ...
The only solution I've found so far is to remove the role_enum method.
We are also experiencing the same issues for a role enum method and being able to search. Any updates? Is this still a bug?
cc @raghugjoshi
Thats crazy. It did not work for me and I came to a thread where they say: "Add a method enum_role and this fixes your problem". Now I am here and I have to remove my method again. A bit confusing, but in the end it worked. Edit: noooooope, I am still getting this error.
Can someone explain what goes wrong?
We are still having problems getting the search work with enums...
field :your_enum, :enum do enum do [ %w(first_option 0), %w(second_option 1), %w(third_option 2) ] end end
this will fix the issue with filtering your enums and it will search by the integer key but problem persists in blank and present
Imagine, that we have got Model with enum field :state and AssociatedModel. When we are trying to attach AssociatedModel to Model from rails_admin interface, the search query fails: it tries to match string and integer.
This bug hides in
lib/rails_admin/adapters/active_record.rb
withinbuild_statement
method:This piece of code generates something like
...state IN ('Search string')
It must return from method in caseif value.blank? || value.is_a?(String)
or something like that.