mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
769 B
769 B
Example of adding a "leaders" relation to Group
Create migration
rails g model GroupLeadership user_id:integer group_id:integer leader_id:integer
Migrate
rake db:migrate
group.rb (containing model) changes
relates :leaders, with: :group_leaderships
- add leaders to attribute_categories hash in config/attributes/group.yml
Create content_groupers/group_leadership.rb
class GroupLeadership < ActiveRecord::Base belongs_to :user
belongs_to :group belongs_to :leader, class_name: 'Character' end
Add attributes to whitelist in groups_controller.rb
- group_leaderships_attributes: [:id, :leader_id, :_destroy],