"undefined method `save' for 2:Fixnum" when saving an association #38

yamilurbina opened this Issue Jun 15, 2012 · 1 comment

2 participants


I have three clases, basically it goes like this:

  • A user has many instances
  • An instance has many workspaces
class User
    include DataMapper::Resource
    has n, :instances

class Instance
    include DataMapper::Resource
    belongs_to :user
    has n, :workspaces

class Workspace
    include DataMapper::Resource
    belongs_to :instance

But when I'm trying to save a new Instance:

u = User.first(:id => id)
i = Instance.new(:name => name, :user => u)


I get the following error:

NoMethodError at 
undefined method `save' for 2:Fixnum
file: resource.rb location: block in save_children line: 1054

Any help with this please?


Sorry this has taken me so long to get back to you. Taking a new job can do that to a guy :(

After all of your model invocations, are you calling DataMapper.finalize ?

Could you send me a failing gist to test with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment