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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:18:55+00:00 2026-06-12T09:18:55+00:00

I have a view for displaying the contents of a Mongoid document. When it

  • 0

I have a view for displaying the contents of a Mongoid document. When it iterates through an array of hashes, it displays the key values pairs as desired but then it dumps the contents of the raw hash unexpectedly. Can anyone explain this behavior?

Here is the view code (in haml);

- @account.attributes.keys.each do |key|
  - if @account[key].class == Array
    %b= key.humanize
    %br
    - @account[key].each do |key2|
      = key2.each do |key3,value|
        #{key3.humanize}: #{value}
        %br
    %br

Here is an embedded collection from the mongo record to be displayed;

"sales" : [
    { "sale_date" : Date( 1256882400000 ),
      "sale_price" : 210000,
      "recording_no" : "2009085729" },
    { "sale_date" : Date( 1160719200000 ),
      "sale_price" : 268300,
      "recording_no" : "2006088793" } ], 

Here is what shows up in the rendered page;

Sales

Sale date: 2009-10-30 06:00:00 UTC

Sale price: 210000

Recording no: 2009085729

{“sale_date”=>2009-10-…006-10-13 06:00:00 UTC

Sale price: 268300

Recording no: 2006088793

{“sale_date”=>2006-10-…ing_no”=>”2006088793”}

Notice the last line of each sale contains the entire hash again! Any clue why?

  • 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-12T09:18:55+00:00Added an answer on June 12, 2026 at 9:18 am

    Change = key2.each to - key2.each.

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

Sidebar

Related Questions

I have a View controller displaying some information (not table views). I have an
I am trying to have an element index view displaying the associated projectname (
I have a view that will be displaying downloaded images and text. I'd like
I have a view model with a couple of properties that are not displaying
I'm missing something fundamental here. I have a table view with each cell displaying
If I have a HomeController displaying its Index view, how would I proceed in
I have an NSFetchedResultsController displaying places in a table view, but when I update
I would like to have the keyboard already displaying when I show my view.
I created an object that extends android.view.View , overriding draw() and have it displaying
I'm trying to have a Table View displaying the content of a generic SQLite

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.