views:

24

answers:

1

Given the parent / child HABTM relationship:

class List < ActiveRecord::Base
  has_and_belongs_to_many :items
end

class Item < ActiveRecord::Base
  has_and_belongs_to_many :lists
end

I need to set up a UI to add Items (children) to a List (parent) from the List create / edit form. The wrinkle is that there are far too many Items records to use checkboxes. An initial thought is to have a popup window that allows the user to browse the collection of Items to find the records to add, but I'm not sure how that would work with new List records (where the parent ID would not yet exist). I'm looking for a solution that will make it easy for the user to navigate the large collection of child records and add them to a parent record in an intuitive manner with the minimum amount of clicks required.

Users will need the ability to browse the Item records to find acceptable choices, so an auto-complete text box which would force users to search for records they want will not work in this case. The child Item records are organized with multiple attributes (e.g. title, author, genre, rating), so my original plan was to set up a table with the Item records with AJAX filter and sort to allow the user to narrow down the Item collection to the desired elements, and to then somehow add selected records to a List. Users do not need to be able to define new Item records while creating a list (i.e. when creating a List, the user will simply select multiple Items from the existing collection).

A: 

I like the auto-completing text-box for lookups like this; it'll depend on if your child-data set is intuitive enough for users to guess.

Jesse Wolgamott
That is a good suggestion, although in the current case, the child records will not be easily found by typing into a text box. The child Items will need to be sorted and filtered, and are more likely to be found by browsing than searching.
Del F
OK, then maybe attack the problem by describing the workflow for the application. How will users setup the List and Items? By creating a list and then choosing with items to add to it? Also: can the items be categorized? [Choose food-isle and then food-item]
Jesse Wolgamott
I'll edit the original post with some of this information.
Del F