Forum: Ruby on Rails Best way to handle namespace collisions?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Wes G. (Guest)
on 2006-05-16 19:52
All,

I have a little namespace collision here.  I am trying to use both
RubyfulSoup (an HTML parser - which I highly recommend by the way) and
the ActionView::Helpers::TextHelper class.  Within the TextHelper class,
there's an attempt to create a new "Tag" object.  However, Tag is also
defined in the RubyfulSoup gem and it is _this_ Tag class whose
initialize method is being called (and failing of course).

So, is my choice simply which Gem to hack and fully qualify the class
name more?

Or is there a way to force one of the modules to look for the class
definition within itself instead of in the path (I doubt it but I
thought I would ask)?

Any other advice?

Thanks,
Wes
Greg F. (Guest)
on 2006-05-16 23:19
(Received via mailing list)
I don't know a solution either, but if Ruby does not have a namespace
solution I think it will be a major stumbling block.

I hit a name collision last week with active_rbac and tracks.  Both
use a table "user", and I had an instance variable named "@user" that
also collided with tracks.

What surprised me the most is that active_rbac actually has its MVC
setup in a active_rbac subdirectory to avoid some collisions, but the
user helper apparently had to live at the base of the helpers
directory.

The more popular engines etc. get, the more this issue is going to bite
people.

Greg

On 5/16/06, Wes G. <removed_email_address@domain.invalid> wrote:
> name more?
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Greg F.
The Norcross Group
Forensics for the 21st Century
Justin C. (Guest)
on 2006-06-03 02:04
(Received via mailing list)
I'm also using Rubyful Soup to do some parsing and my own Tag model is
colliding with Soup's Tag.  Still haven't found a good solution yet
either.

Justin
Wes G. (Guest)
on 2006-06-03 02:21
Justin C. wrote:
> I'm also using Rubyful Soup to do some parsing and my own Tag model is
> colliding with Soup's Tag.  Still haven't found a good solution yet
> either.
>
> Justin

Well, at least you can control your namespace.  I had to make a local
copy of Rubyful Soup to only include only part of one of the gems that
it depends on.

Good luck.

Wes
This topic is locked and can not be replied to.