I am new to working with ember.js and currently dealing with two models - User
and Role
App.User = DS.Model.extend({
name: DS.attr('string'),
roles: DS.hasMany('role')
});
App.Role = DS.Model.extend({
name: DS.attr('string')
});
My goal is to assign or remove roles for a specific user in my application. To achieve this, I need to compare the roles associated with the user against all available roles by looping through and comparing two controllers.
When displaying the assigned roles to a user in the user/edit template
, I use the following code:
Assigned Roles: {{#each role in roles}}*{{role.name}}{{/each}}
However, I also need a RolesController in the same route that will display all available roles regardless of the user. Setting up this controller in UserEditRoute may cause conflicts due to naming conventions.
The objective is to list all roles with checkboxes, where the roles assigned to the user are pre-checked and others remain unchecked.