dimanche 2 août 2015

How to set up fixtures for HABTM?

Organization and User have a many-to-many relationship through Relationship. I read here about setting up fixtures for this:

#users.yml
one:
  organizations: one
  email: one@example.com
  ...

#organizations.yml
one:
  name: "Company A"
  ...

This should already set up a relationship between the organization and user, without needing relationships.yml.

Here's my problem: In the relationship table certain variables (roles) get set for the relationship, e.g.: a moderator boolean. How can I include these variables in the fixtures? Do I then require relationships.yml after all (it's nice not to need that one)?

For example, something like:

#users.yml
one:
  organizations: one(moderator: true)
  email: one@example.com
  ...

Aucun commentaire:

Enregistrer un commentaire