Merge pull request #310 from aboutsource/fix_deleting_memberships_on_workgroup_destroy
Fix deleting memberships on workgroup destroy
This commit is contained in:
commit
459b2826d3
3 changed files with 10 additions and 7 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
5
db/migrate/20140921104907_remove_stale_memberships.rb
Normal file
5
db/migrate/20140921104907_remove_stale_memberships.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class RemoveStaleMemberships < ActiveRecord::Migration
|
||||
def up
|
||||
Membership.where("group_id NOT IN (?)", Group.ids).delete_all
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue