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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:33:38+00:00 2026-05-27T04:33:38+00:00

I recently inherited an old merb app that uses datamapper as its orm. I’m

  • 0

I recently inherited an old merb app that uses datamapper as its orm. I’m not too familliar with DM so there is probably something obvious I’m overlooking. I have a simple relationship between two models, which is not required, as follows:

class User
  include DataMapper::Resource

  property :id,      Serial
  property :name,    String, :length => 100, :nullable => false

  belongs_to :upload, :required => false
end

class Upload
  include DataMapper::Resource

  property :id,           Serial
  property :filename,     String

  has n, :users
end

But for some reason it won’t let me save a user without an attached upload:

> u = User.create :name => 'foo'
 => #<User @id=nil @name=nil @upload_id=nil>
> s.errors.full_messages
 => ["Upload must not be blank"]

Just to be sure I tried setting :required => false on the “has n” side too but it made no difference of course.

All this on merb 1.0.13 and datamapper 0.10.1


EDIT: The answer below is correct but I did find a workaround, you can add :nullable => true to make this work, as follows:

belongs_to :upload, :required => false, :nullable => true
  • 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-27T04:33:39+00:00Added an answer on May 27, 2026 at 4:33 am

    There used to be a bug in old DM which was causing this behavior. I’d strongly suggest porting this app to recent Rails & DM.

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

Sidebar

Related Questions

I recently inherited an iPhone app. The original developer did not understand memory management
I recently inherited an e-commerce app (Java/Struts) that I'm porting to Rails. The thing
I have recently inherited a J2EE Struts web app that was written back in
I recently inherited a Silverlight web project that uses WCF services to handle asynchronous
I recently inherited a small Java program that takes information from a large database,
I recently inherited a VBA macro that needs to have validation logic added to
I recently inherited a Ubuntu Hardy box that acts rather funky out-of-the-box. The first
I've recently inherited an application that makes very heavy use of session, including storing
I've recently inherited the job of maintaining a database that wasn't designed very well
I recently inherited a warehouse which uses views to summarise data, my question is

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.