Hey all,
I've just jumped onto the DataMapper bandwagon, so just a quick bit of
help if you can spare a min.
I've got 2 models - yes I know they're identical that's a whole other
issue I'm working on :D -
class Category
include DataMapper::Resource
property :id, Serial
has n, :entries, :through => Resource
property :title, String, :nullable => false
property :description, Text
property :updated_at, DateTime, :default => Proc.new
{ DateTime.now }
end
class Entry
include DataMapper::Resource
property :id, Serial
has n, :categories, :through => Resource
property :title, String, :nullable => false
property :description, Text
property :updated_at, DateTime, :default => Proc.new
{ DateTime.now }
end
and a spec testing the association.
it "should have entries" do
category = Category.create(:title => "A category")
entry = category.entries.create(:title => "A title")
category.entries.include?(entry).should eql(true)
end
but my spec is failing with the error message
The property 'category_id' is not a public property.
If I alter my spec to this it passes:
it "should have entries" do
category = Category.create(:title => "A category")
entry = Entry.create(:title => "A title")
category.entries << entry
category.save
category.entries.include?(entry).should eql(true)
end
Am I doing something wrong here, why is build/create methods trying to
mass assign to a protected property and how can I fix this?
Cam
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---