Skip to content

Instantly share code, notes, and snippets.

@erikh
Created March 25, 2012 03:36
Show Gist options
  • Save erikh/03cff05699998f7829b4 to your computer and use it in GitHub Desktop.
Save erikh/03cff05699998f7829b4 to your computer and use it in GitHub Desktop.
require 'db'
class Report < Sequel::Model
one_to_many :resources
many_to_one :node
def resources=(resources)
save unless id
remove_all_resources
add_resources(resources)
end
def add_resources(resources)
resources.each do |resource|
add_resource(resource)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment