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.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-05-16 17: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
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-05-16 21: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 Gamble <weyus@att.net> wrote:
> name more?
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
291ce712bdd6aa97abad3b693ca045d1?d=identicon&s=25 Justin Chen (Guest)
on 2006-06-03 00: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
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-06-03 00:21
Justin Chen 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.