Merge pull request #310 from aboutsource/fix_deleting_memberships_on_workgroup_destroy

Fix deleting memberships on workgroup destroy
This commit is contained in:
wvengen 2014-09-22 09:06:25 +02:00
commit 459b2826d3
3 changed files with 10 additions and 7 deletions

View File

@ -1,7 +1,7 @@
# Groups organize the User.
# A Member gets the roles from the Group
class Group < ActiveRecord::Base
has_many :memberships
has_many :memberships, dependent: :destroy
has_many :users, :through => :memberships
validates :name, :presence => true, :length => {:in => 1..25}
@ -37,5 +37,3 @@ class Group < ActiveRecord::Base
end
end
end

View File

@ -0,0 +1,5 @@
class RemoveStaleMemberships < ActiveRecord::Migration
def up
Membership.where("group_id NOT IN (?)", Group.ids).delete_all
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140521142651) do
ActiveRecord::Schema.define(version: 20140921104907) do
create_table "article_categories", force: true do |t|
t.string "name", default: "", null: false