# Routes and Forms

**URL:** <https://www.ruby-forum.com/t/routes-and-forms/173649>\
**Category:** Rails\
**Created:** [August 12, 2009, 6:04pm UTC](https://www.ruby-forum.com/t/routes-and-forms/173649 "2009-08-12T18:04:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [August 12, 2009, 6:04pm UTC](https://www.ruby-forum.com/t/routes-and-forms/173649/1 "2009-08-12T18:04:29Z")

</div>

Hello G.s,

I am totally new to rails so sorry if I ask some silly questions, I am  
also totally confused which is likely self inflicted!

So I am learning rails and rjs - I have two models

Manufacturers  
Models

So Manufacturers would contain things like Ford, Aston Martin  
and Models would contain the cars like

Ford -\> Focus, Escort  
Ferrari =\> DB7, DB6, DB5

So I have the simple rails framework working, so firstly a index of  
‘Manufacturers’ would show all the Manufacturer’s, you could then click  
a Manufacturer and it would display all the models for that  
Manufacturer, and then you can click a Model and you can ‘edit’ that  
models.

But what I want is to have them all on one page - so what I want is the  
index page has a select, once you select a manufacturer it grabs all the  
models and now displays them in a ‘select’ - you then chose a model and  
it then loads the ‘edit’ page.

Now what I have done so far is in my index.erb

# Listing Manufacturer
\<% form\_remote\_for "manufacturer", :html =\> {:id =\> 'form1', :name =\> 'form1'} do |f| %\>

| Please select Manufacturer | \<%= collection\_select(:manufacturer, :id, @manufacturer, :id, :manufacturer, {:include\_blank =\> ''}, {:onchange =\> "document.form1.onsubmit()"}) %\> |

\<% end %\>

And my show.rjs

will do something like

page.replace\_html :show\_models, :partial =\> ‘show’, :object =\>  
@manufacturer

Now I tried to do something similar to the index.erb for each ‘model’  
e.g.

| Please select Model | \<%= collection\_select(:model, :id, @manufacturers.models, :id, :title, {:include\_blank =\> ''}, {:onchange =\> "document.form1.onsubmit()"}) %\> |

But of course this submits the form to the same controller/action for  
the manufacturers not the models controller… Anyone got any advice on  
how to do this sort of thing?

Much Appreciated

Paul
