table - Create an activerecord class that has a field that behaves like an enum (but is a reference to another activerecord class) -


sorry long title, question rather simple:

i have 2 classes, player , role (they activerecord table)

class player {     ...various fields...      [belongsto("roleid")]     public role role {get;set;} }  class role {     ...various fields...      [property]     public string name {get;set;} } 

a player, can have 1 role, (for me), doesn't matter if role has 0-1-2-many players, omit hasmany attribute (my example easy, database bigger this). role behaving user-defined enum, possible this? correct way?

edit 1: if have similar situation need role belogs 1 player (onetoone), again omit part "role" class (so role doesn't know association)

if specify belongsto attribute , not hasmany attribute, want done, role doesn't matter if has 0-1-2-many players.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -