I have two models
term_versions (build from acts_as_versioned)
They are related but for all intents and purposes different models.
'term_versions' has this association not available to 'term':
has_many :technical_definitions, :dependent => :destroy
accepts_nested_attributes_for :technical_definitions, :allow_destroy =>
When i create a new 'term' i want to also allow for the creation of
technical_definitions related to its versions, but i can't find a good
DRY way of doing it.
The best form i've come up with looks something like this:
<% form_for(@term, ..options, do |f| %>
<% fields_for "version[technical_definitions_attributes]",
new_tech_def do |td_fields| %>
<% end %>
<% end %>
The problems with the above are numerous. For one, it's hackish and i
can't reuse that code. Second, it only somewhat works for 1 technical
definition. If i try to give it a collection to work with it goes
haywire. Third, if the model validations fail, and the form has to be
reloaded, those fields are not preserved by the new action, and the
browser loses state. I can get around this last one by adding even more
hackish lines to my controller code.
Working with Rails 2.3 means i don't have the :namespace option on
fields_for which would really help.
Any suggestions fellow devs?