There is no automatic way (if I understand correctly - when the user chooses carname in some select box, the options in another select box must change accordingly). I will assume carmodel is a select box but if it's a textbox you can still use the same solution. You basically have 2 options:
- in both options you must hook into on change event of the select box. you can use e.g. jQuery for this: http://api.jquery.com/change/
- Option 1 without Ajax: output all the car models in JSON format into the page (like var carModels = {...}), and then in on change event of the carname select box, use javascript/jQuery to add only the appropriate models from carModels into the select box options
- Option 2 with Ajax: on select of the carname select box, send Ajax request ($.post from jQuery) to the server with the information about selected value in carname. the server should give back the list of appropriate car models in JSON format. after you get this result back, just insert all the values into the select box. For returning this data in json format from server you need to create a post action like get_models. To return the data in json format you can use render :text => @models.all.to_json
The Ajax solution will be easier because you need less Javascript logic.
To see how to add options to select box with jQuery look at this question: What is the best way to add options to a select from an array with jQuery?