ruby on rails - Single Table Inheritance with Conditions -
i have model user , model recruiter. currently, these 2 separate tables, want make them one.
current:
- user: id, username, password, name
- recruiter: id, user_id
ideal:
- user: id, username, password, role (recruiter, admin)
i understand basics of sti. i'm wondering is, when perform methods on new recruiter controller (that inherits user) how make sure methods calling on users recruiter? thus, queries along lines of... select * users role = 'recruiter'
everything.
that rails takes care of you, out of box. not have manually query on particular type of user, query on right model.
i must mention default rails assumes sti_column called type
, can overridden role
easily.
Comments
Post a Comment