Hi everyone,
Ok, first off, I’ve read
http://wiki.rubyonrails.com/rails/pages/HowToPopulateYourDbFromScript
and it was a huge help. I’m loading info with no issue.
EXCEPT when I try to load info into multiple tables, i.e., adding
relationships. I have 2 questions:
- I have a Person model with has_many :entitlements. Entitlement
has_and_belongs_to_many :people. (Maybe they should both be HABTM?).
There’s a entitlements_people table. When I’m loading them via
script, what is the correct way to do so? How do I add one? Many?
Add on to what’s already there?
person = Person.new
person.entitlement = ??
person.save
- If the data I’m loading uses entitlement names and not IDs, how do
I specify the ID? For instance, “wireless” is an entitlement with an
ID of 1. In my data, I have “wireless” and not “1”. Do I create a
translation table in my script, or can I ID the entitlement based on
the name?
Thank you!
Sean