foodsoft/plugins/messages/app/controllers/messagegroups_controller.rb
Patrick Gansterer 01cf6431a9 Add messagegroup
Messagegroups are a new kind of group. Every user can join and leave such a
group on her own. They are useful to create topics for mails.

E.g. if there is a weekly newsletter we can create a new messagegroup for
it and every user which is interested in receiving the newsletter can join
the corresponding group.
2016-03-04 18:32:57 +01:00

18 lines
515 B
Ruby

class MessagegroupsController < ApplicationController
def index
@messagegroups = Messagegroup.order("name")
end
def join
@messagegroup = Messagegroup.find(params[:id])
@messagegroup.users << current_user
redirect_to messagegroups_url, :notice => I18n.t('messagegroups.join.notice')
end
def leave
@messagegroup = Messagegroup.find(params[:id])
@messagegroup.users.destroy(current_user)
redirect_to messagegroups_url, :notice => I18n.t('messagegroups.leave.notice')
end
end