Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4540700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:07:22+00:00 2026-05-21T15:07:22+00:00

class A include DataMapper::Resource def self.default_repository_name :alt_db end property :aid, Integer, :key => true

  • 0
class A
    include DataMapper::Resource

    def self.default_repository_name
        :alt_db
    end

    property :aid, Integer, :key => true
    # other stuff

    belongs_to :b, :model => 'B', :child_key => [ :bid ]

end

class B
    include DataMapper::Resource

    # this one is in the default repo

    property :bid, Integer, :key => true
    # other stuff

    belongs_to :c, :model => 'C', :child_key => [ :cid ]
end

class C
    include DataMapper::Resource

    # this one is in the default repo

    property :cid, Integer, :key => true
    # other stuff
end

If I just have A and B, this works fine. If I add C, however, I get an error:

dm-core/model/property.rb:73:in `new’: wrong number of arguments (4 for 3) (ArgumentError)

If I want to make a chain of relationships with DataMapper, so that I can give an ID in one place and get a piece of data that’s, say, four tables away through a series of references to subsequent tables’ primary key ID field, how can I do this?

EDIT: Digging into the DM source from the stack trace:

DataMapper.repository(other_repository_name) do
    properties << klass.new(self, name, options, type)
end

That’s where the error is raised. Indeed, in this case klass is a DataMapper Integer property, and it’s initialize method only accepts three options (model, name, and an options hash).

This whole block is only executed because I’m using more than one repository, though B and C are in the same one so I don’t know if that sheds any light on why it’s erroring on the cid property.

EDIT2:

I have tried all permutations, and it appears that when you’re chaining, once you cross a database-boundary, that must be the end of the chain. For example, since A is :alt_db and B is :default, B is as deep as I can go, regardless of whether C is :default, :alt_db, or a third option.

If instead both A and B were :default, or both were :alt_db, and then C were the opposite one, C would be as deep as I could go.

I don’t understand this behavior really, though.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:07:23+00:00Added an answer on May 21, 2026 at 3:07 pm

    You found a bug actually. It’s been fixed in master. You can try grabbing sources from git and see if it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I define the following model... class Foo include DataMapper::Resource property :name, String, :key
say I have class MyClass include DataMapper::Resource property :id, Serial property :my_property, Text end
I've got two models that look like this class Stage include DataMapper::Resource property :id,
Using the following classes and their associations. class Repository include DataMapper::Resource property :id, Serial
In my model I have class Alias include DataMapper::Resource belongs_to :user property :id, String,
I have this model class User include DataMapper::Resource include BCrypt property :id, Serial property
I work with Sinatra. This is my models. class Post include DataMapper::Resource property :id,
Model: class Country include DataMapper::Resource property :id, Serial property :name, String property :continent, String
I have 3 related models: class Transaction include DataMapper::Resource property :id, Serial property :volume,
I have the following model in datamapper: class Student include DataMapper::Resource property :id, Serial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.