I have set up my first HABTM tables (hosts
and owners
) with a join table (hosts_owners
). My tests seem to be working fine and similarly so do the web pages.
So, my next question is how to insert new data and their respective relationships (ie., join table information). Since I expect there will be two primary ways of inserting new data:
- Programmatically, where the content is retrieved from other sources and saved into the tables
- Manually, users will use the web pages to add new entries.
So, for each of the above, what is the "rails" way of ensuring that each time a host is added at least one owner is also added? (And vice versa.) All of the books and articles I found seem to stop at the point of creating the tables and models.