Best way to update one-to-many relationship

whats the best way to either add or remove entries for a one-to-many
relationship.

Should I just put all the entries associated with a record into form
fields, and than on submit delete all the entries, and then reenter all
of the ones on the current form.

This would take into account addition and deletions to the database.

whats the best way to do this with many-to-many assuming you want new
entries created and not just linking two entries in different tables?

Eric G. wrote:

whats the best way to either add or remove entries for a one-to-many
relationship.

Should I just put all the entries associated with a record into form
fields, and than on submit delete all the entries, and then reenter all
of the ones on the current form.

This would take into account addition and deletions to the database.

Clearing and replacing the whole set of related objects is a fine
way to do it as long as:

  1. The existing objects aren’t linked to other records via their
    current ids.

  2. The records aren’t too big.


We develop, watch us RoR, in numbers too big to ignore.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs