how should I render views when users habtm roles.

2019-07-29 17:23发布

问题:

ok here is my issue...

user habtm groups(roles)

i have views for admins, boardmembers, managers, and vps.

so when an user have just one role the app reads the role and we're going fine... BUT when he/she/it have two or more roles it just take the first one and dissmiss the others...

the questions

  • how should i manage those role so the user can choose what view to see?
  • should i tell the user what role he wants to play after login? Ex: made him decide (want's to play admin, want's to play manager, etc)
  • is there a way the user can play two roles at the same time at one session? Ex: I have two roles (vps, manager). render two views in one?
  • or should i choose a view for that role that have more privilege? Ex: I have two roles (admin, manager) so i use admin views not the manager's ones.

a lot of questions... so start answering hahaha thanks guys...

回答1:

It's difficult to answer because the sort of questions you're asking require us to decide how your application will work. You have to do that yourself and make appropriate design & programming based on your decision.

As for display of HABTM records, I usually use checkboxes or some graphical readonly equivalent.

My suggestion is that you look around the web to see how it works on other sites - social sites like Flickr and Facebook are a good hunting ground as they have lots of groups, categories etc.



回答2:

user admin routing... and have many prefixes. and may be in the place where you display user information. you can also list the other roles he can play.