nested fields and search questions

80 views
Skip to first unread message

Karl Baum

unread,
Sep 11, 2012, 7:33:58 AM9/11/12
to rails...@googlegroups.com
Have a few rails_admin questions. Think i know the answers but wanted to double check;

1) Is it possible to add search filters by fields on nested models? For example, property belongs to city which has a name. Is it possible to filter properties by city#name?

2) When exporting to CSV, is it possible to export fields from nested models two levels deep? In my case, space belongs_to property which belongs to city. I would like to export the city name.

3) Is it possible to have search criteria joined together with "or" instead of "and". For example, i want to search all users with name michael or jon.

thx!

-karl

Benoit Bénézech

unread,
Sep 13, 2012, 12:37:03 PM9/13/12
to rails...@googlegroups.com
1) yes :)

config.model Property do
  field city do
    searchable :name # or 'city.name' or  { City => :name }
  end
end

2) You can add custom fields that can behave the same

config.model Space do
  export do
    ....
    field property_city do
      export_value do
        bindings[:object].property.city.name
      end
    end
    ....
  end
end

3) no :( It would need a refactoring of the search engine and the filter widgets... :/

Benoit Bénézech

unread,
Sep 13, 2012, 12:38:59 PM9/13/12
to rails...@googlegroups.com
For the second one, it's :property_city instead of property_city.
And you may need to add a few other methods if it complains.
Reply all
Reply to author
Forward
0 new messages