Skip to content

Instantly share code, notes, and snippets.

@spockz
Created October 30, 2012 15:49
Show Gist options
  • Save spockz/3981081 to your computer and use it in GitHub Desktop.
Save spockz/3981081 to your computer and use it in GitHub Desktop.
undefined property or relationship '<<' on Category
Same happens when doing rekenserviceinstance.categories.new(category: somecategory).
undefined property or relationship 'new' on Category
class Rekenservice
include DataMapper::Resource
property :id, Serial
has n, :categories, :through => Resource
def self.new(hash)
hash[:categoriesss].each do |category|
categories << Category.get(category)
end
hash.delete :categoriesss
super hash
end
def update(hash)
#categories.clear
#hash[:categories].each do |category|
# categories.new(category: Category.get(category))
#end
hash! :categories
super hash
end
end
class Category
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true
has n, :rekenservices, :through => Resource
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment