I am starting out in rails and am loving it! Thanks to all the
I made a web app that had about 7 models, with some referring to each
other, eg a team had a member and so on.
This relationship was not enforced in the model or in the database, it
was kind of hacked together in the view by creating html select
I found very quickly that deleting models and adding new ones meant
that objects that should not be related were.
I thought at first I should implement the correct cascading deletes.
I have looked into this a little more and have now redefined all my
models correctly, eg a team has_many :members.
I looked at the mysql database this created and there are no foreign
question 1) should there be foreign key relations in mysql db? I used
the script/generate model and then rake db:migrate
class Developer < ActiveRecord::Base
question 2) in my conceptual model my developer belongs to a team. So
i have the model above. Should there be a relationship in team
describing how the link exists to developer? Currently mine is empty:
class Team < ActiveRecord::Base
thanks in advanced for any help!