-
Notifications
You must be signed in to change notification settings - Fork 1
users and groups
William Lubelski edited this page Apr 11, 2014
·
2 revisions
(Assuming you want the group to have users with ids 3 and 4 in it.)
pry> g = Group.new(name: 'My Group Name')
pry> g.users << User.find(3)
pry> g.users << User.find(4)
pry> g.save(Assuming you want to add user id 18 to group 25.)
pry> g = Group.find(25)
pry> g.users << User.find(18)
pry> g.save(Assuming you want to make user 12 an admin of group 20, and that 12 is already a member of 20.)
pry> gp = GroupParticipation.where(user_id: 12, group_id: 20).first
pry> gp.group_admin = true
pry> gp.saveIf you've just wiped your database you don't have any groups to make users through, so you have to assemble at least one through pry.
pry> u = User.new email: 'alice@example.com', password: 'a'
pry> u.saveSet an existing user to receive email when they get a message.
pry> u = User.find(20)
pry> u.send_me_mail = true
pry> u.save