I'd like to be able to use the "Add Filter" dropdown so admins can search for posts that have been flagged a particular name.
My Post model
class Post < ActiveRecord::Base
belongs_to :user
has_many :post_flags
has_many :flags, through: :post_flags
config/initializers/rails_admin.rb
config.model 'Post' do
exclude_fields :rank, :embedded_url, :attached_picture, :updated_at
object_label do
"#{bindings[:post].user.name}"
end
list do
field :text_content
field :created_at
field :user_id
field :likes_number
field :post_flags
end
end
I've tried adding "searchable" to the field :post_flags to no avail. Any help would be much appreciated.
I'm currently trying to work through a similar problem.
Adding the following to your rails admin config should allow you to add a post_flag filter:
field :post_flags do
searchable :name
end
However, you will get an SQL error when when you try to use the search filter.
We may have to hack RailsAdmin's MainController. Checkout this post: http://blog.endpoint.com/2013/07/hasmany-filter-in-railsadmin.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.