Google Groups

Re: [rails_admin] Search and filter problems


Nick Roosevelt 25-Jun-2012 18:37
Posted in group: rails_admin
I have read the wiki.  I have read the code.  I have tried all the ways to configure it that I could find, including the way you list (but I think you mean "searchable [:association_field1, :association_field2]" - changing the first 2 for a 1.  When I configure the associated fields, the code that I think adds the search configuration (rails_admin/config/fields/base.rb lines 73 to 104) does not seem to run - I have tried putting "debugger" statements and print statements (though it does seem to run for the primary model fields.  I can't figure out where in between my code and the code that does the configuration that the flow control is getting stopped.  I don't really fully understand how all that meta-code works.  Can anyone point me in some direction that allows me to find what is going wrong?  Is there something special I need to do in the model(s)?  It does do the sorting, and it does display it, but it does not set it up for searching.

On Mon, Jun 25, 2012 at 8:10 AM, Steph Skardal <st...@endpoint.com> wrote:
On 06/20/2012 03:17 AM, Nick Roosevelt wrote:
I have an app with rails 3.1.3 and rails_admin.  I can not seem to get it to do searching with the associations.  Is anyone else having any similar problem?  I have spent many hours trying many things.  I can get the filtering working, but the search will only search the main table's fields.  Does this sound at all familiar to anyone?

Hi Nick,

Yes, I just came across this and did some debugging to see what the cause is. By default, the searchable field is the referencing field only (e.g. abstract_model_table.association_name_id). The searchable fields are configurable, so you can add something similar to the following in your list method in the config:

config.model do ParentModelName do
  list do
    field :association do
      searchable [:association_field2, :association_field2]
    end
  end
end

The wiki covers this here (with an example): https://github.com/sferik/rails_admin/wiki/List in the Fields searching section.

~Steph

-- 
Steph Skardal
End Point, Corp

ph: 336-245-8807
st...@endpoint.com

--
You received this message because you are subscribed to the Google Groups "rails_admin" group.
To post to this group, send email to rails...@googlegroups.com.
To unsubscribe from this group, send email to rails...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rails_admin?hl=en.