#1244 ✓not-applicable
Fred Wu

Auto-generated foreign keys aren't accessible from Model.update

Reported by Fred Wu | April 15th, 2010 @ 10:18 PM

For example, the following model has a 'belongs_to' association.

  class ExampleModel
    include DataMapper::Resource
    property :id,    Serial
    property :title, String
    belongs_to :some_other_models

ExampleModel.create (and .new + .save) works fine.

However, upon using ExampleModel.update({attributes}), the auto-generated foreign key could not be accessed:

The attribute 'some_other_model_id' is not accessible in ExampleModel

The work-round is to manually set a some_other_model_id property in the model, but I believe the behaviour is inconsistent between save and update, thus should be fixed.

Any thoughts?

P.S. I did a search on lighthouse and cannot see this reported, I apologise it's duplicated.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »