Created
October 30, 2012 15:49
-
-
Save spockz/3981081 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undefined property or relationship '<<' on Category | |
Same happens when doing rekenserviceinstance.categories.new(category: somecategory). | |
undefined property or relationship 'new' on Category |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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