views:

384

answers:

1

Hey Guys

I am trying to create a car application, each car belongs to a make and model, but only certain makes have certain models.

So I would like a series of select boxes that are populated dynamically based on the previous, however I also would like to add another record to that select box if you cant find the one you want.

I would just like to know your thoughts on how to accomplish this in a rails way?

Cheers Adam

A: 

Jquery select boxes http://www.texotela.co.uk/code/jquery/select/ will do your dependent boxes for you. As for it not being in the list you can add a link, something like "Model not in our list? + add a new one" This then swaps the select for a text box. Offer a link to select from there to get back if they want.

I've actually just used a form with both the select or Add a new one box on it if you want less hassle in the view, not as nice but still works. You can then use the find_or_create method for the AR relationship.

tsdbrown
Thats great! Cheers!
Adam Carlile