Replies: 4 comments
-
I am currently facing similar issues when attempting to update to the latest ActiveAdmin version (from the I am seeing similar errors - depending on the model, I also get a
Which seems related to @Chucheen's problem. This might point to a problem in how the URL query params are passed down? Using |
Beta Was this translation helpful? Give feedback.
-
Hey, so I managed to find a solution (which works for my setup, but might give some helpful pointers): For context, we're using an older version of Why does this matter?Well, taking a resource called # doesn't work
class User < ApplicationRecord
class << self
def ransackable_attributes(_auth_object = nil)
%i(name email key)
end
def ransackable_associations(_auth_object = nil)
%i(organization)
end
end
end
# surprisingly*, _does_ work
class User < ApplicationRecord
class << self
def ransackable_attributes(_auth_object = nil)
# NOTE: you can also call super + ... here, but that will lead to a deprecation
# warning, suggesting the solution below
authorizable_ransackable_attributes + %i(name email key)
end
def ransackable_associations(_auth_object = nil)
authorizable_ransackable_associations + %i(organization)
end
end
end
# * actually not super surprising, since this will .... carry the scope? This then also should allow using ActiveAdmin normally: ActiveAdmin.register User do
filter :key, filters: %i(eq)
filter :name, filters: %i(eq cont)
filter :email, filters: %i(eq)
index do
id _column
column :key
column :email
column :name
end
end |
Beta Was this translation helpful? Give feedback.
-
The same issue happens for me. I am using Rails |
Beta Was this translation helpful? Give feedback.
-
@Chucheen I was hitting the same issue and just managed to fix it by using strings instead of symbols def ransackable_attributes(_auth_object = nil)
- %i(name email key)
+ %w(name email key)
end See activerecord-hackery/ransack#1538 Hopefully that works for you to. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I upgraded activeadmin to version 3.2.5. I know it comes with changes and i'm having the time of my life now making filters work. At the beginning none of my "Registered" admin files were opening because of the ransack changes. I started investigating and now the filters i wanted are shown. I dind't stop to think if the filters were working or not, just making them visible 😂
Now after i modified many of the files and i thought of trying to use them and none of them work.
Expected behavior
Be able to filter the data when applying filters
Actual behavior
I get errors the following errors:
When filtering admin_users
when filtering another class called document_requests
The error seems to be happening here: active_admin/filters/active_filter.rb:75 since this method returns nil
When inspecting, the condition has the following
Condition <predicate: cont, values: ["sds"]>
. It doesn't seem to haveattributes
How to reproduce
Here's my admin file for
admin_users
Here's my AdminUser model
My ActiveAdmin configuration
I'm using rails 7.1 and active_admin 3.2.5. Hopefully this is enough for you guys to point me in the right direction.
Thanks for your hard work!
Beta Was this translation helpful? Give feedback.
All reactions