Teams are a core piece of functionality for many applications these days and Jumpstart comes preconfigured with them so you don't have to do any of the heavy lifting.
Every user has a personal team they are an admin of. A personal team does not allow other users on it. This allows our code to work exactly the same whether we're adding resources privately for a user or a team of users.
Github is a great example of this case. Repositories can be personal or on an organization (their name for teams) and by setting them up this way, we can have our code treat them exactly the same.
Users can create additional teams and invite other users to join them. Once created, users can switch which team they're viewing from their account dropdown in the navbar.
Each team has separate billing, which allows you to setup flexible subscriptions based upon the team. This is also similar to Github where you can pay for a personal account or you can pay for an organization account.
If you don't want to use the teams functionality, you can simply remove links to the teams. We encourage you to keep the teams functionality around as it allows you flexibility in the future should you choose to implement teams later on.
Users can be assigned a role for each team they are a part of. By default, we only provide an
admin role, but you can add more rules in
app/models/team_member.rb. These roles will be listed in the UI when adding or editing a team member.
You can check the role on the team member to restrict access to certain functionality on the team as needed.
To access the current team member or roles, you can use the following helpers in your controllers and views:
current_team_member #=> TeamMember current_roles #=> [:admin]
You can also access the roles individually on the TeamMember model:
team_member = TeamMember.new team_member.admin? #=> false team_member.admin = true team_member.admin? #=> true team_member.active_roles #=> [:admin]