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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:33:16+00:00 2026-06-10T08:33:16+00:00

I am trying to set up versioning on my mongomapper model using the https://github.com/Bramanga/mongo_mapper_acts_as_versioned

  • 0

I am trying to set up versioning on my mongomapper model using the https://github.com/Bramanga/mongo_mapper_acts_as_versioned gem that I forked. However, whenever I try to save my Finding model, it fails if I try to save it with a Time type (which I have to use because MongoDB only supports utc times, and not dates).

Model:

class Finding
  require 'carrierwave/orm/mongomapper'
  include MongoMapper::Document
  ensure_index 'finding.document'
  plugin MongoMapper::Acts::Versioned 

  attr_accessible :found_date, :target_date, :abated_date

  key             :found_date,          Time
  key             :target_date,         Time
  key             :abated_date,         Time
  
  belongs_to      :client
  many            :uploads, :dependent => :destroy
  many            :documents, :dependent => :destroy

  timestamps!

  def found_date=(date)
    if date.present?
      self[:found_date] = Chronic.parse(date).utc.beginning_of_day
    else
      self[:found_date] = nil
    end
  end

  def target_date=(date)
    if date.present?
      self[:target_date] = Chronic.parse(date).utc.beginning_of_day
    else
      self[:target_date] = nil
    end
  end

  def abated_date=(date)
    if date.present?
      self[:abated_date] = Chronic.parse(date).utc.beginning_of_day
    else
      self[:abated_date] = nil
    end
  end
end

Terminal output:

Loading development environment (Rails 3.0.10)

1 pry(main)> finding = Client.first.findings.build

=> <#Finding _id: BSON::ObjectId(‘4fc67c8f4e484f267c000002’), client_id: BSON::ObjectId(‘4f7119884e484f25bd005ee8’), custom_fields: {}, legacy_attachments: [], tags: []>

[2] pry(main)> finding.save

=> true

[3] pry(main)> finding.found_date = "12/24/2012"

=> "12/24/2012"

[4] pry(main)> finding.save

BSON::InvalidDocument: ActiveSupport::TimeWithZone is not currently supported; use a UTC Time instance instead.
from /home/bramanga/.rvm/gems/ruby-1.9.2-p290@actionlog/gems/bson-1.6.2/lib/bson/bson_c.rb:24:in `serialize’

I’m not sure how to fix this. Maybe I’m just doing it wrong. Any ideas?

  • 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-10T08:33:17+00:00Added an answer on June 10, 2026 at 8:33 am

    Fixed my own issue after forking the repo. My solution is here.

    The issue is related to mongodb‘s supported date types. It only supports a UTC timestamp format. I added my own escape_mongo method to convert to a safe timestamp type before being persisted to the database:

    def escape_mongo(obj)       
        obj.is_a?(Date) || obj.is_a?(Time) ? Date.to_mongo(obj) : obj   
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to set up a model observer. AuditTrail is triggered however it's not passing
Im trying set the single table inheritance model type in a form. So i
I am using mac lion and eclipse indigo. I am trying set it up
Trying to set up an extension method in .Net 3.0 using generics and I
Trying to set up the svn commit with trac using this script. It is
Im trying to set active classes in a nav using php. Now I need
Trying to set up a menu so that I have border-left on each menu
Trying to set up a cassandra cluster, but it tells me that I have
Trying to set orientation in manifest file, using a string qualifier android:screenOrientation=@string/orientation Works on
I'm trying set up an execution account following the steps here: http://msdn.microsoft.com/en-us/library/ms156302.aspx I follow

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.