Skip to content

Instantly share code, notes, and snippets.

@nurey
Created May 17, 2011 18:33
Show Gist options
  • Save nurey/977064 to your computer and use it in GitHub Desktop.
Save nurey/977064 to your computer and use it in GitHub Desktop.
class ScheduleGroup < ActiveRecord::Base
include AbstractGroup
has_and_belongs_to_many :schedules
end
class Schedule < ActiveRecord::Base
has_and_belongs_to_many :schedule_groups
end
module AbstractGroup
before_destroy :removable?
def removable?
self.schedules.empty? # self.collection.empty?
end
end
@nurey
Copy link
Author

nurey commented May 17, 2011 via email

@samuelkadolph
Copy link

Sorry, make that groupings.concat(associations).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment