diff options
author | Heiko Bernlöhr <Heiko.Bernloehr@FreeIT.de> | 2021-12-16 21:00:33 +0100 |
---|---|---|
committer | Heiko Bernlöhr <Heiko.Bernloehr@FreeIT.de> | 2022-09-15 09:54:09 +0200 |
commit | fdacc0b6be33dfe1db0b5a01f578b43b10185631 (patch) | |
tree | 880375ad8452b970e642f1d2536433d6cf8e6f72 /app | |
parent | 8b7cb6b761741a201044be076bd75eb0e28566b9 (diff) | |
download | ecs-fdacc0b6be33dfe1db0b5a01f578b43b10185631.tar.gz ecs-fdacc0b6be33dfe1db0b5a01f578b43b10185631.zip |
Rails 5.2.6
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin/participants_controller.rb | 4 | ||||
-rw-r--r-- | app/models/membership.rb | 2 | ||||
-rw-r--r-- | app/models/message.rb | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/app/controllers/admin/participants_controller.rb b/app/controllers/admin/participants_controller.rb index 550e904..f206913 100644 --- a/app/controllers/admin/participants_controller.rb +++ b/app/controllers/admin/participants_controller.rb @@ -118,7 +118,7 @@ class Admin::ParticipantsController < ApplicationController def index_communities @participant = Participant.find(params[:id]) - @communities=Participant.find(params[:id]).memberships.collect {|i| i.community }.distinct.sort{|x,y| x.id <=> y.id } + @communities=Participant.find(params[:id]).memberships.collect {|i| i.community }.uniq.sort{|x,y| x.id <=> y.id } end # lists all those communities which the participant has not yet joined @@ -168,7 +168,7 @@ private leaved_messages << Membership.find_by_participant_id_and_community_id(participant.id, cid).messages leaved_messages << Community.find(cid).messages end - leaved_messages.flatten.compact.distinct + leaved_messages.flatten.compact.uniq end def participant_params diff --git a/app/models/membership.rb b/app/models/membership.rb index 42371de..02a9698 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -23,8 +23,8 @@ class Membership < ApplicationRecord -> { select("name, description, id") }, :class_name => "Community", :foreign_key => "community_id" - has_many :messages, :through => :membership_messages has_many :membership_messages, :dependent => :destroy + has_many :messages, :through => :membership_messages after_create :postroute diff --git a/app/models/message.rb b/app/models/message.rb index 922cae2..374ea22 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -20,8 +20,8 @@ class Message < ApplicationRecord require 'exceptions' - has_many :memberships, :through => :membership_messages has_many :membership_messages + has_many :memberships, :through => :membership_messages has_many :events, :dependent => :destroy has_many :community_messages, :dependent => :destroy has_many :communities, :through => :community_messages |