Topic: Updating 2 models using one single form

Hi,

I'm writing a simple document versioning system and have created two models, one called DOC and the other called VERSION:

CREATE TABLE `docs` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` varchar(250) NOT NULL default '',
  `type` varchar(100) NOT NULL default '',
  `description` text,
  PRIMARY KEY  (`id`)
)

CREATE TABLE `versions` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `doc_id` int(11) unsigned NOT NULL default '0',
  `employee_id` int(11) unsigned NOT NULL default '0',
  `created_on` datetime NOT NULL default '0000-00-00 00:00:00',
  `version` float NOT NULL default '0',
  `comments` text,
  `size` int(11) NOT NULL default '0',
  `url` varchar(250) NOT NULL default '',
  PRIMARY KEY  (`id`)
)


For the file part, I've added a file_column in the definition of the VERSION model:
class Doc < ActiveRecord::Base
  belongs_to  :project
  has_many    :versions
end

class Version < ActiveRecord::Base
  file_column :filename

  belongs_to  :docs
end


I'm a bit perplexed as to how to create the first document. Ideally, i'd want to have a simple form that just includes the name, description and file. But how can I create a single form that created both models?

Thanks.

Re: Updating 2 models using one single form

Have you seen this tutorial?

Railscasts - Free Ruby on Rails Screencasts

Re: Updating 2 models using one single form

Exactly what I was looking for.
As always, this site saved me countless hours googleing.