On Sep 15, 5:08 am, clintjhill <[EMAIL PROTECTED]> wrote:
> I have a DataMapper resource named Registration. I have 3 "belongs_to"
> statements. I have run the automigrate statement and the schema for
> the table reflects the proper foreign keys.
>
> The problem is how I'm not able to construct a new Registration with
> the foreign key names. Maybe I'm not understanding DataMapper
> properly.

oops - seems I posted about the same problem (should've searched
first) so you're not the only one who expects this to work.

> Do I have to perform "get!" on each association first then pass them
> to the initializer? Is there documentation somewhere that will make me
> look foolish for asking?

To get round this I've currently done a nasty hack to save performing
an additional get.  This is no doubt pretty likely to break in future
versions of dm as it's not using any public api calls but it was the
only way I could see to get round the issue without issuing an extra
query....

You can get at the child model of the belongs_to association like so:

child_model = association.instance_variable_get(:@parent)

then save the child. So in a Registration object you can get at (say)
an agent model by doing:

agent.instance_variable_get(:@parent)

Hope this helps - use at your own peril - I'm sure there must be a
better/more proper way of achieving this.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to