Multiple Models In One Form

I've browsed several articles and tutorials for days and cannot figure
out how to make this thing work the way I want it to. Basically I'm
building a listings manager.

I want users to be able to create available details. For instance, if
they're doing listings for vehicles, they would create details for
price, make, model, year, etc, and that is handled by my Details
model. No problem.

Then, when a user creates a listing, I want the view to show the usual
stuff for the listing (name, description, etc), I have a category
wired up and working fine, but then I want those Details to show up
with text boxes next to them so that they can fill out the details for
a particular item. I've created a ListingDetail model which
has :listing_id, :detail_id, and :value in it.

I cannot, after browsing all the tutorials out there, figure out how
to do this. I'll post the code I have below. It doesn't work right,
but perhaps someone can help?

# _form.html.erb: and again this probably is laid out right....
    <b>Name</b><br />
    <%= f.text_field :name %>

    <b>Description</b><br />
    <%= f.text_area :description, :rows => 4 %>

  <b>Category</b><br />
    <%= f.collection_select(:category_id, @categories, :id, :name) %>

    <b>Details</b><br />
    <% fields_for :listing_details do |d| %>
      <% @details.each do |detail| %>
          <%= %>: <%= d.text_field :value, :detail_id => %>
    <% end %>
  <% end %>

# listings_controller.rb which I have no idea what I'm supposed to
have here in order to save them all...

  def create
    @listing =[:listing])
    @listingdetail =[:listing_details])

    respond_to do |format|
        flash[:notice] = 'Listing was successfully created.'
        format.html { redirect_to(admin_listings_url) }
        format.xml { render :xml => @listing, :status
=> :created, :location => @listing }
        format.html { render :action => "new" }
        format.xml { render :xml => @listing.errors, :status
=> :unprocessable_entity }

# listing_detail.rb
class ListingDetail < ActiveRecord::Base
  belongs_to :listing

# listing.rb
class Listing < ActiveRecord::Base
  belongs_to :category
  has_many :listing_details

# detail.rb
class Detail < ActiveRecord::Base

I'm assuming you've read these.