thanks.
The difference between has and belongs_to is not intuitive to me.  I'm
definitely not looking for magic.
I wanted to create an association and property by doing something
like:

has 1, :shell_user, {:class_name => User, :field =>
'shell_user_id', :nullable => false,  :index => true}

When I do, I don't get any errors, I just don't get any fields defined
in my tables either.

This I assumed would give the object/table a property/field of
shell_user_id and an association to get/set the object with the
shell_user accessors.

In my case, I don't need the "other end" to know anything.  I just
wanted a simple id reference to a user object.  Seems like there
should be an easy way to do this.
So now, I'm back to the way I had it before.  I have a property for
the id and I hand code accessors to look up the user by this id.  I
thought what I was trying to do should be the simplest form of a
datamapper association.

thanks, Jon



On Dec 22, 2:54 am, "Dan Kubb (dkubb)" <[email protected]> wrote:
> Hi Jon,
>
> > when auto_migrate! creates the table., I expected a field
> > shell_user_id.  Nothing.  I have tried other variations but no luck.
>
> > Am I supposed to declare the field separate from the association?
> > like:
>
> >  property :shell_user_id, Integer
> >  has 1, :shell_user, :class_name => User
>
> The rule of thumb to remember is that when you use has() the property
> will be created in the Model at the *other end* of the association.
>
> If you want the property to be created in the current model, you use
> belongs_to.  I know it's a bit confusing, and belongs_to almost
> screams for a few aliases because "belongs to" doesn't always clearly
> describe how a child is owned by a parent.  We're going to resolve
> this in the near future in a way that should be alot clearer -- I
> won't say too much now because I haven't worked out all the details to
> know if what we're thinking of is possible yet.
>
> Dan
> (dkubb)
--~--~---------~--~----~------------~-------~--~----~
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