Hi I'm a bit confused by the following belongs_to behaviour in datamapper. If I have the two resources Member and Subscription as shown below:
class Member include DataMapper::Resource property :id, Integer, :serial => true property :name, String end class Subscription include DataMapper::Resource property :id, Integer, :serial => true property :year, Integer property :member_id, Integer belongs_to :member end member = Member.create(:name => "Fred") subscription = Subscription.create(:year => 2008, :member => member) I can't seem to save any changes to the member resource via the subscription, so if I try: subscription.member.name = "John" Neither of the following persist the new name of the member in the database. subscription.save subscription.member.save Is this expected behavior? And if so does it mean that it's not possible to update the contents of a model in a belongs_to association from the parent? It seems that the offending code is in the save method in many_to_one.rb(61): return true unless parent.new_record? This means that the associated resource won't save unless the parent is new. I don't understand the reason for this logic/behaviour - can anyone enlighten me? All the best Rupert --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
