Hi Paul, thanks for your reply.

I looked at many_to_many.rb:60 and I see exactly what you mean.

I tried to monkey around but I haven't been lucky so far. Here are the
three roads I tried:

1- Tried to change ManyToMany.setup so that it parses the model_name
variable for "::" and then iteratively recreate each top/mid level
module down to the actual model class.
2- Tried to flatten/concatenate the model names by removing any "::"
in them.
3- Tried to remove altogether the parent namespaces at runtime by
using Extlib::Inflection.demodulize(...)

In all cases, I ended up breaking something since other code elsewhere
seems to not be expecting "::" into the model names. Also,
Extlib::Inflection.underscore(...) sometimes created problems because
it was replacing the "::" by a "/" - which looks like it is what it's
supposed to do - but the code using it got confused by the "/".

My guess is that this assumption is not localized to many_to_many.rb.
I might give it a shot again (I'll get to learn the code :) ) and will
keep you posted if I ever make any progress.

Do you think I should create a new ticket in the bug tracker or reopen
one of the existing ones?

Regards,
Francis


On Sep 11, 6:47 pm, paulcody <[EMAIL PROTECTED]> wrote:
> Francis: I'm and newcomer to DataMapper myself; I'm having the same
> issue that I'm trying to debug now... The offending code line 60 in
> many_to_many.rb breaks as the ruby methods
> Module.const_defined?, .const_get, .const_set are not namespace
> aware.  However, even when you workaround that line, it still breaks
> for reasons that I'm still working on...  Any thoughts from datamapper
> developers?
>
> Thanks,
> Paul
>
> On Sep 11, 1:16 pm, Francis Joanis <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > I'm quite new to DataMapper and while implementing my model I
> > encountered the following error when trying to implement a many-to-
> > many relationship with objects that are within namespaces.
>
> > I am running dm-core from the git master. I also saw that two tickets
> > (that could be related) had been opened on the bug tracker (tickets
> > 202/203).
>
> > The error is:
>
> > /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/
> > many_to_many.rb:60:in `const_defined?': wrong constant name
> > Circus::Show::ClownMask (NameError)
> >         from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/
> > associations/many_to_many.rb:60:in `setup'
> >         from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/
> > associations.rb:122:in `has'
> >         from circus.rb:10
>
> > Here's the example code (sorry if it looks lame :) ):
>
> > (CODE_BEGIN)
> > require 'rubygems'
> > require 'dm-core'
>
> > module Circus
> >    module Show
>
> >       class Clown
> >          include DataMapper::Resource
> >          property :id, Serial
> >          has n, :masks, :through => Resource
> >       end
>
> >       class Mask
> >          include DataMapper::Resource
> >          property :id, Serial
> >          has n, :clowns, :through => Resource
> >       end
>
> >    end
> > end
>
> > DataMapper.setup(:default, 'sqlite3::memory:')
> > DataMapper.auto_migrate!()
> > (CODE_END)
>
> > Note that if I remove the Circus and Show namespaces, everything seems
> > to work fine.
>
> > Thanks,
> > Francis
--~--~---------~--~----~------------~-------~--~----~
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