I have a DataMapper resource named Registration. I have 3 "belongs_to"
statements. I have run the automigrate statement and the schema for
the table reflects the proper foreign keys.
The problem is how I'm not able to construct a new Registration with
the foreign key names. Maybe I'm not understanding DataMapper
properly.
Here is the offending statement and error:
irb(main):001:0> @reg = Registration.new(:server_id => 1, :agent_id =>
1, :context_id => 1)
NameError: server_id= is not a public property
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-
core/resource.rb:502:in `attributes='
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-
core/resource.rb:496:in `each_pair'
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-
core/resource.rb:496:in `attributes='
from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-
core/resource.rb:576:in `initialize'
from (irb):1:in `new'
from (irb):1
irb(main):002:0>
Here is the model:
class Registration
include DataMapper::Resource
property :id, Integer, :serial => true
property :created_at, DateTime
property :updated_at, DateTime
validates_present :agent, :server, :context
belongs_to :agent
belongs_to :server
belongs_to :context
end
Do I have to perform "get!" on each association first then pass them
to the initializer? Is there documentation somewhere that will make me
look foolish for asking?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---