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 8852459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:24:24+00:00 2026-06-14T13:24:24+00:00

I have a DataMapper::Collection Object. Each of it’s entries has a created_at property. I

  • 0

I have a DataMapper::Collection Object. Each of it’s entries has a created_at property. I want to render the entries into html tables, one table per day (I use Sinatra for that).

It was no problem to render everything into one table, but I didn’t get it to do so for every day. I thought of an array of DataMapper::Collection objects over which I would just iterate and do the job. But I don’t know how to build such an array :/

Does anyone know how to solve my problem, or does anyone have a different/better approach?
Thanks in advance!

  • 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-06-14T13:24:25+00:00Added an answer on June 14, 2026 at 1:24 pm

    You have (at least) two options. The first is to let the database do the work for you. I don’t know about datamapper but most database mappers (!) have functionality to group using SQL’s GROUP BY. In this case you would have to use a database function to get the date out of the timestamp and then group on that. This is the fastest option and if you and future maintainers are familiar with relational databases probably also the best.

    The second option is to to the mapping in your code. I can’t come up with an elegant Ruby thing right now but you could at least do:

    mapped_result = Hash.new [] # initiates each new entry with empty array
    mapper_collection.each do |one_record|
      mapped_result[one_record.created_at.strftime '%Y-%m-%d'] << one_record
    end
    

    and then you can get to record for a day with

    mapped_result['2012-11-19']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a collection class called MySet: class MySet include DataMapper::Resource property :id, Serial
Lets say I have the following DataMapper resources: class Post include DataMapper::Resource has n,
I'm just diving into Datamapper (and Sinatra) and have a question about associations. Below
I have an DataMapper class which has some private and public methods. The DataMapper
I have this model class User include DataMapper::Resource include BCrypt property :id, Serial property
In my model I have class Alias include DataMapper::Resource belongs_to :user property :id, String,
I have run into an interesting dilema. In a DataMapper class, I am generating
I have something like: class User include DataMapper::Resource property :id, Serial property :username, Text
Using Codeigniter and Datamapper : I have 2 tables: tags and clients . Clients
I have 3 related models: class Transaction include DataMapper::Resource property :id, Serial property :volume,

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.