# Virtual Domain extension for mental

**URL:** <https://www.ruby-forum.com/t/virtual-domain-extension-for-mental/79441>\
**Category:** Radiant CMS\
**Created:** [December 15, 2006, 3:59am UTC](https://www.ruby-forum.com/t/virtual-domain-extension-for-mental/79441 "2006-12-15T03:59:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [December 15, 2006, 3:59am UTC](https://www.ruby-forum.com/t/virtual-domain-extension-for-mental/79441/1 "2006-12-15T03:59:56Z")

</div>

I’ve updated the Virtual Domain behavior to be a page type in  
mental. I’ve uploaded a tar.gz for people to try (I don’t have svn  
on my server and don’t feel the need to set it up for thist):

[http://silverinsanity.com/~benji/virtual\_domain.tar.gz](http://silverinsanity.com/~benji/virtual_domain.tar.gz)

Should work near identically to the original, except that it works on  
mental of course. Be sure to read the README for instructions on how  
to install the needed patch to Radiant.

If anyone could figure out why I’m getting the following error in two  
of the tests, I’d appreciate it:

ArgumentError: vendor/rails/activesupport/lib/active\_support/  
dependencies.rb:399:in `to\_constant\_name’: Anonymous modules have no  
name to be referenced by

~~ Brian

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [December 15, 2006, 3:18pm UTC](https://www.ruby-forum.com/t/virtual-domain-extension-for-mental/79441/2 "2006-12-15T15:18:49Z")

</div>

On Dec 14, 2006, at 9:59 PM, Brian G. wrote:

> ArgumentError: vendor/rails/activesupport/lib/active\_support/  
> dependencies.rb:399:in `to\_constant\_name’: Anonymous modules have no  
> name to be referenced by

This happens, I think, when there is an undefined constant referenced  
in a method. Could you please indicate which two tests you are seeing  
this in? Is it when your behavior is installed only?

aiwilliams

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [December 15, 2006, 3:57pm UTC](https://www.ruby-forum.com/t/virtual-domain-extension-for-mental/79441/3 "2006-12-15T15:57:02Z")

</div>

On Dec 15, 2006, at 9:17 AM, Adam W. wrote:

> On Dec 14, 2006, at 9:59 PM, Brian G. wrote:
> 
> > ArgumentError: vendor/rails/activesupport/lib/active\_support/  
> > dependencies.rb:399:in `to\_constant\_name’: Anonymous modules have no  
> > name to be referenced by
> 
> This happens, I think, when there is an undefined constant referenced  
> in a method. Could you please indicate which two tests you are seeing  
> this in? Is it when your behavior is installed only?

It’s in the tests for VirtualDomainPage in the plugin (mostly  
unchanged from the tests for VirtualDomainBehavior). Specifically,  
it’s from:

virtual\_domain\_page\_test.rb:88:in `test\_default\_sitemap’  
default\_map = @page.children.inject({}) { |memo, page| memo  
[page.slug] = page.slug; memo }

virtual\_domain\_page\_test.rb:42:in  
`test\_find\_first\_child\_for\_no\_config\_unknown\_host’  
assert\_equal @page.children.find(:all).find { |child|  
child.published?}, Page.find\_by\_url("/")

As far as I can tell from mucking with the code, I get the error any  
time I call any method on @page.children, where @page is a  
VirtualDomainPage. But, thankfully, only in the tests. (The  
extension works properly, AFAICT.)

~~ Brian

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [December 15, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/virtual-domain-extension-for-mental/79441/4 "2006-12-15T16:49:13Z")

</div>

On Dec 15, 2006, at 9:55 AM, Brian G. wrote:

> As far as I can tell from mucking with the code, I get the error any  
> time I call any method on @page.children, where @page is a  
> VirtualDomainPage.

It’s interesting to me that in VirtualDomainPageTest#setup, a Page  
instance is created, it’s class\_name set to VirtualDomainPage, and  
then it is reloaded as a VirtualDomainPage instance. Immediately  
afterward, @page.children.create is invoked, which doesn’t blow up.

Looking closer, I found that the ‘Anonymous module’ that has ‘no name  
to be referenced by’ is NoCachePage, defined in the PageTestHelper.  
The stack and ruby-debug output is below. I confess that I don’t know  
enough at the moment about all the interactions of your tests with  
the PageTestHelper, but this might help someone else, or you, figure  
out wazzup.

* * *

## #5 /Users/aiwilliams/Documents/workspace/radiantextensions/test/…/ config/…/vendor/rails/activerecord/lib/active\_record/base.rb:1066:in `instantiate\_without\_callbacks’ (rdb:1) l= [1061, 1070] in /Users/aiwilliams/Documents/workspace/ radiantextensions/test/…/config/…/vendor/rails/activerecord/lib/ active\_record/base.rb 1061 unless columns\_hash.include? (inheritance\_column) 1062 allocate 1063 1064 else 1065 begin =\> 1066 compute\_type(subclass\_name).allocate 1067 rescue NameError 1068 raise SubclassNotFound, 1069 "The single-table inheritance mechanism failed to locate the subclass: ‘#{record [inheritance\_column]}’. " + 1070 "This error is raised because the column ‘#{inheritance\_column}’ is reserved for storing the class in case of inheritance. " + (rdb:1) p subclass\_name “NoCachePage” (rdb:1)

HTH,

aiwilliams

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [December 15, 2006, 6:47pm UTC](https://www.ruby-forum.com/t/virtual-domain-extension-for-mental/79441/5 "2006-12-15T18:47:38Z")

</div>

On Dec 15, 2006, at 10:47 AM, Adam W. wrote:

> It’s interesting to me that in VirtualDomainPageTest#setup, a Page  
> instance is created, it’s class\_name set to VirtualDomainPage, and  
> then it is reloaded as a VirtualDomainPage instance. Immediately  
> afterward, @page.children.create is invoked, which doesn’t blow up.

The back and forth was the easiest way I could find to get the  
correct class for the Page without writing new fixtures myself. And  
it was the closest analogue to the way the original set the behavior  
before beginning the tests.

I tried playing around with that @page.children.create, which didn’t  
change anything (much to my surprise). It was only when I tried to  
access @page.children.\* in the tests that it bombed.

I might just try to re-write the tests completely. Currently I’m  
just trying to make the smallest changes needed to get the 0.5  
behavior to work properly as a mental page type. I don’t want to  
make any large changes as it’s not originally mine… And now that I  
look at it, there’s no licensing information in the original code.  
Hmmm…

> Looking closer, I found that the ‘Anonymous module’ that has ‘no name  
> to be referenced by’ is NoCachePage, defined in the PageTestHelper.  
> The stack and ruby-debug output is below. I confess that I don’t know  
> enough at the moment about all the interactions of your tests with  
> the PageTestHelper, but this might help someone else, or you, figure  
> out wazzup.

[cut debug output]

Ah! A ruby debugger! How the heck could I have forgotten it  
existed! Bad me! Especially after the hours I’ve spent with gdb…

The PageTestHelper must be mucking with something before the tests to  
add the NoCachePage. I’ll have to see what’s going on, and it’ll be  
much faster with a debugger at my fingertips.

~~ Brian

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [December 15, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/virtual-domain-extension-for-mental/79441/6 "2006-12-15T19:09:41Z")

</div>

On Dec 15, 2006, at 12:47 PM, Brian G. wrote:

> The PageTestHelper must be mucking with something before the tests to  
> add the NoCachePage. I’ll have to see what’s going on, and it’ll be  
> much faster with a debugger at my fingertips.

Close, but no cigar. I think PageTestHelper is never getting loaded,  
but the fixtures use the classes inside. Bingo. Added a require for  
page\_test\_helper, and viola!

New version of extension (with correctly running tests!) uploaded to:

[http://silverinsanity.com/~benji/virtual\_domain.tar.gz](http://silverinsanity.com/~benji/virtual_domain.tar.gz)

And, as a side note, I can’t get “ruby -rdebug” or ruby-debug to work  
on virtual\_domain\_page\_test or page\_test. It dies on “uninitialized  
constant Radiant”, in config/boot.rb:50. But it runs without the  
debug module just fine.

~~ Brian
