Dmitry Polyakovsky
Dmitry Polyakovsky

Reputation: 1585

RailsAdmin with polymorphic associations

I am using, Rails 4.1, RailsAdmin 0.8.1 and Mongoid 5.0.1. I defined has_many / belongs_to relationship between Products and Pictures RailsAdmin generates a Product dropdown in the Picture model. I can choose Product or I can search for Product.

I implemented polymorphic association between Products, Pictures and Employees. Now when I edit Picture I have 2 dropdowns - to choose type (Product or Employee) and 2nd to choose the actual record.

The problem is RailsAdmin is trying to load the entire Employee or Product list into 2nd dropdown. I have many thousands Employees and eventually it timesout. Any ideas how to search?

Upvotes: 1

Views: 735

Answers (1)

rohan
rohan

Reputation: 1656

The dropdown lists are populated when page is loaded. The second dropdown will have everything you send during page loading (before you have chosen 'type' in first dropdown).

What I think you want can be achieved using ajax to send a request when first dropdown is selected, retrieve the values and then populate your second dropdown list.

Some sources you can read. link1 link2 link3

Upvotes: 1

Related Questions