We have implemented gem 'rails_admin', '~> 1.4.3'
in our application.
The issue we are facing here is in customizing the output values in the multi-select dropdown in rails admin.
For example: Student
has many Teachers
. So while creating a Student
record we will have a multi-select dropdown of Teachers
. Here we only want those Teachers
who are in active
state, not all the teachers.
To achieve the same, we have implemented something like below in the student_admin.rb
file.
create do
field :name do
required true
end
field :teachers do
visible do
Teacher.where(state: 'active')
end
end
end
The above code neither gives any error nor filters the only active teachers.
Can someone help to get the expected result here. Any suggestion will be highly appreciated.