On Tue, Jan 12, 2010 at 10:47:41PM -0800, Jeremy Evans wrote:
> On Jan 12, 7:31 pm, Jeff Turner <[email protected]> wrote:
> > It seems the problem is that I use the Symbol :reporter both as the
> > table column name (which I can't change, unfortunately) and as the
> > name of the Ticket field. If I change:
> >         Ticket.many_to_one :reporter, :key=>:reporter, :class=>User
> > to:
> >         Ticket.many_to_one :myreporter, :key=>:reporter, :class=>User
> > then this works:
> >         puts Ticket[1].myreporter
> >
> > Could this be considered a bug? Or am I doing something stupid?
> 
> The association name has to be different than the key name.  That is
> by design.  If you can't change your schema, you won't be able to use
> reporter as an association name (well, without aliasing, and even then
> some things would probably break).
> 
> I deliberately choose to have the association methods call methods to
> get the key values instead of looking directly in the values hash, as
> that allows more flexibility (outside of this particular use case).

Thanks for the explanation.

Jeff

> Jeremy
-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en.


Reply via email to