Hello,
I’m having a hard time explaining this, so I hope i can say this
correctly. I have these tables:
people
id
fname
lname
departments
id
name
buildings
id
name
room
wtkeys
id
key_number
key_way
Issued_keys
id
people_id
department_id
building_id
wtkey_id
date_issued
My question is when i need to insert a new issued_key do I just do
something like:
person.fname = "Robert"
person.lname = "Boone"
person.save!
dept = Department.new
dept.name = "IT"
dept.save!
building = Building.new
building.name = "CC"
building.save!
wtkey = Wtkey.new
wtkey.key_number = "1234"
wtkey.key_way = "AAAA"
wtkey.save!
issued_key = IssuedKey.new
issued_key.people_id = person.id
issued_key.department_id = dept.id
issued_key.building_id = building.id
issued_key.wtkey_id = wtkey.id
issued_key.date_issued = Time.now
issued_key.save!
This seems very un-rails-like to me (but I could be wrong). Is there
there a better way to do this. And I won’t object to changing the
database.
Thanks,
Robert Boone