Johannes Held
unread,May 15, 2012, 8:19:09 AM5/15/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to datam...@googlegroups.com
I have a model named Fact. A fact belongs to many other models and holds some attributes. Think of it as a data-warehouse fact table.
class Fact
include DataMapper::Resource
belongs_to :patientposition, :key => true
belongs_to :controlpointcount, :key => true
belongs_to :radiationtype, :key => true
belongs_to :collimatormovement, :key => true
belongs_to :beamcount, :key => true
belongs_to :marctype, :key => true
property :valid, Boolean, :required => true, :default => true
property :marctestdate_count, Integer, :required => true, :default => 0
property :realvortest1_count, Integer, :required => true, :default => 0
timestamps :at
end
All of the other models are described in the same way:
class Name
include DataMapper::Resource
property :id, Serial
property :value, String, :required => true
validates_uniqueness_of :value
end
If I want to first_or_create a fact issuing e.g.
Fact.first_or_create("patientposition_id"=>2, "controlpointcount_id"=>3, "radiationtype_id"=>1, "collimatormovement_id"=>1, "beamcount_id"=>4, "marctype_id"=>3)
I get this error (which renders me helpless):
wrong number of arguments (1 for 0)
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/model/property.rb:218:in `valid?'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-validations-1.2.0/lib/dm-validations.rb:51:in `save_self'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1006:in `block in _save'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1222:in `run_once'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1005:in `_save'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/resource.rb:405:in `save'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-validations-1.2.0/lib/dm-validations.rb:40:in `block in save'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-validations-1.2.0/lib/dm-validations/context.rb:16:in `in_context'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-validations-1.2.0/lib/dm-validations.rb:40:in `save'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-validations-1.2.0/lib/dm-validations.rb:130:in `create'
/Users/jo/.rvm/gems/ruby-1....@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/model.rb:444:in `first_or_create'
This error appears whether I use the ids or the actual model instance queried from the database.
Any hints or ideas?
--
Johannes