Hello Guys,

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

<h1>Listing Manufacturer</h1>
<% form_remote_for "manufacturer", :html =>
{:id => 'form1', :name => 'form1'}  do |f| %>
<table border="1" width="50%">
  <tr>
    <td width="30%">Please select Manufacturer</td>
    <td><%= collection_select(:manufacturer, :id, @manufacturer, :id,
:manufacturer, {:include_blank => ''}, {:onchange =>
"document.form1.onsubmit()"}) %></td>
  </tr>
</table>
</div>
<div id="show_models"></div>
<% 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.

<table border="1" width="50%">
  <tr>
    <td width="30%">Please select Model</td>
    <td><%= collection_select(:model, :id, @manufacturers.models, :id,
:title, {:include_blank => ''}, {:onchange =>
"document.form1.onsubmit()"}) %></td>
  </tr>
</table>

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
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to