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

  • SEARCH
  • Home
  • 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 4124546
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:45:17+00:00 2026-05-20T23:45:17+00:00

Just using DataMapper for the first time. I have set up a table in

  • 0

Just using DataMapper for the first time. I have set up a table in a MySQL database and am connecting to that. I have defined the following mapping:

class Track_Scan
    include DataMapper::Resource

    property :item_id,                  Integer
    property :current_station_id,       Integer
    property :next_station_id,          Integer
end

It returns the right number of items – e.g. if there are five records in the DB for a given id, Track_Scan.all(:item_id => my_id) will yield a group of five objects – but when I call each on this, I see the same object five times:

#<Track_Scan:0x7fcbcfca59c0>
#<Track_Scan:0x7fcbcfca59c0>
#<Track_Scan:0x7fcbcfca59c0>
#<Track_Scan:0x7fcbcfca59c0>
#<Track_Scan:0x7fcbcfca59c0>

rather than five different objects with different values in their current_station_id and next_station_id as they actually do in the table.

Any help?

  • 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-20T23:45:17+00:00Added an answer on May 20, 2026 at 11:45 pm

    Your model is missing a key. If you want to use a composite key you need to do this:

    class Track_Scan
      include DataMapper::Resource
    
      property :item_id,            Integer, :key => true
      property :current_station_id, Integer, :key => true
      property :next_station_id,    Integer, :key => true
    end
    

    Also, after all your models are required you need to call:

    DataMapper.finalize
    

    Hope this helps

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

Sidebar

Related Questions

I just started using SVN, and I have a cache directory that I don't
I know that just using rand() is predictable, if you know what you're doing,
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I just started using the WPF WebBrowser that is included in Net 3.5 SP1.
I have a basic Ruby app that I am building with Sinatra, Datamapper and
I have several cases and I am just using simple if ... if else
How would I do the following, preferably just using CSS (but possibly jquery too)
I'm using Datamapper 1.0 with sinatra and sqlite3 as backend. I have some devices,
Are table aliases faster than just using the tablename instead? Or doesn't this make

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.