# RFC: Alias Behavior

**URL:** <https://www.ruby-forum.com/t/rfc-alias-behavior/80537>\
**Category:** Radiant CMS\
**Created:** [December 28, 2006, 3:35pm UTC](https://www.ruby-forum.com/t/rfc-alias-behavior/80537 "2006-12-28T15:35:52Z")\
**Posts on this page:** 8\
**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 28, 2006, 3:35pm UTC](https://www.ruby-forum.com/t/rfc-alias-behavior/80537/1 "2006-12-28T15:35:52Z")

</div>

I just hacked together a dirt-simple “alias” behavior. This came out  
of a desire to have a second domain serve up a portion of the main  
site (using the Virtual Domain Behavior). All it does is take the  
“source” page part and use that to find (by slug) another page to  
use. It allows children of the original page to be overridden by  
children of the alias page.

[http://silverinsanity.com/~benji/radiant/alias\_behavior.rb](http://silverinsanity.com/~benji/radiant/alias_behavior.rb)

To use it, just place the above file in RAILS\_ROOT/app/behaviors

As a note, “find\_page\_by\_path” seems like it would be generically  
useful, especially in environments where the page URLs are very  
different from the page slugs. (Along with \<r:if\_page path=“”\> and  
\<r:unless\_page\>, which would check to see if the current page matches  
a slug path. I’ll write those up when/if I need them.)

If anyone has any questions or comments, feel free to let me know.  
If you spot any glaring errors, PLEASE let me know. I’d like to have  
people more familiar with Radiant’s core take a peek at it before  
trying to use it in a production environment.

(BTW, is mental stable enough for production use and is there an easy  
migration path from 0.5.2 yet?)

Thanks,  
~~ 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 28, 2006, 4:04pm UTC](https://www.ruby-forum.com/t/rfc-alias-behavior/80537/2 "2006-12-28T16:04:01Z")

</div>

Looks interesting, Brian. I know I’m wasn’t good in the past about this  
myself, but some tests would be nice.

Sean C.  
[seancribbs.com](http://seancribbs.com)

---

<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 28, 2006, 5:04pm UTC](https://www.ruby-forum.com/t/rfc-alias-behavior/80537/3 "2006-12-28T17:04:25Z")

</div>

On Dec 28, 2006, at 10:03 AM, Sean C. wrote:

> Looks interesting, Brian. I know I’m wasn’t good in the past about  
> this myself, but some tests would be nice.
> 
> Sean C.  
> [seancribbs.com](http://seancribbs.com)

Yeah, that’s part of the “hacked together” part. I didn’t know how  
it would end up working when I started, so I couldn’t attempt tests.  
I’ll work on fixing that in a bit.

~~ 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 28, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/rfc-alias-behavior/80537/4 "2006-12-28T18:06:54Z")

</div>

Brian G. wrote:

> like the following:
> 
> /Users/brian/dev/radiant/radiant-0.5.2/test/…/config/…/vendor/rails/  
> activerecord/lib/…/…/activesupport/lib/active\_support/  
> dependencies.rb:100:in `const\_missing’: uninitialized constant  
> ActionController::TestProcess (NameError)

Strange, that would indicate that it can’t find Rails. Is Rails in your  
vendor directory or do you have it installed via gems?

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<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 28, 2006, 6:16pm UTC](https://www.ruby-forum.com/t/rfc-alias-behavior/80537/5 "2006-12-28T18:16:57Z")

</div>

On Dec 28, 2006, at 12:05 PM, John W. Long wrote:

> Strange, that would indicate that it can’t find Rails. Is Rails in  
> your  
> vendor directory or do you have it installed via gems?

Both, actually. I have the vendor/rails from the tarball and Rails  
1.1.6 installed via RubyGems. Both ruby (1.8.4) and gem (0.8.11) are  
installed via fink.

What I find truly odd is that it seems to jump from vendor to gems:

> > ```
> > from /sw/var/lib/gems/1.8/gems/actionpack-1.12.5/lib/
> > 
> > ```
> > 
> > action\_controller/integration.rb:16  
> > from /sw/lib/ruby/1.8/rubygems/custom\_require.rb:21:in  
> > `require' from /Users/brian/dev/radiant/radiant-0.5.2/test/../ config/../vendor/rails/activerecord/lib/../../activesupport/lib/ active_support/dependencies.rb:147:in`require’

~~ 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 28, 2006, 6:00pm UTC](https://www.ruby-forum.com/t/rfc-alias-behavior/80537/6 "2006-12-28T18:00:45Z")

</div>

On Dec 28, 2006, at 10:03 AM, Sean C. wrote:

> Looks interesting, Brian. I know I’m wasn’t good in the past about  
> this myself, but some tests would be nice.
> 
> Sean C.  
> [seancribbs.com](http://seancribbs.com)

I can’t get any tests running in my 0.5.2 setup (from  
radiant-0.5.2-2.tgz). Any time I try to run any test, I get errors  
like the following:

/Users/brian/dev/radiant/radiant-0.5.2/test/…/config/…/vendor/rails/  
activerecord/lib/…/…/activesupport/lib/active\_support/  
dependencies.rb:100:in `const_missing': uninitialized constant ActionController::TestProcess (NameError) from /sw/var/lib/gems/1.8/gems/actionpack-1.12.5/lib/ action_controller/integration.rb:16 from /sw/lib/ruby/1.8/rubygems/custom_require.rb:21:in `require’  
from /Users/brian/dev/radiant/radiant-0.5.2/test/…/  
config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/  
active\_support/dependencies.rb:147:in `require' from /Users/brian/dev/radiant/radiant-0.5.2/test/../ config/../vendor/rails/railties/lib/test_help.rb:10 from /sw/lib/ruby/1.8/rubygems/custom_require.rb:21:in `require’  
from /Users/brian/dev/radiant/radiant-0.5.2/test/…/  
config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/  
active\_support/dependencies.rb:147:in `require’  
from ./…/test\_helper.rb:8  
from page\_test.rb:1

Kinda keeps me from figuring out my own tests.

~~ 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 28, 2006, 7:13pm UTC](https://www.ruby-forum.com/t/rfc-alias-behavior/80537/7 "2006-12-28T19:13:15Z")

</div>

On Dec 28, 2006, at 12:44 PM, John W. Long wrote:

> Please file a ticket about this and I will make sure it is fixed  
> for the  
> next release.

Ticket 469:  
[http://dev.radiantcms.org/radiant/ticket/469](http://dev.radiantcms.org/radiant/ticket/469)

~~ 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 28, 2006, 6:45pm UTC](https://www.ruby-forum.com/t/rfc-alias-behavior/80537/8 "2006-12-28T18:45:09Z")

</div>

Brian G. wrote:

> What I find truly odd is that it seems to jump from vendor to gems:  
> Mmmm. This seems to be a problem with the tarball. I just downloaded it  
> myself and am receiving the same error.

For now, I’d recommend installing via subversion (which seemed to work  
nicely for me):

$ svn co [http://dev.radiantcms.org/svn/radiant/tags/rel\_0-5-2/radiant](http://dev.radiantcms.org/svn/radiant/tags/rel_0-5-2/radiant)  
$ cd radiant  
$ cp config/database.mysql.yml config/database.yml  
$ script/setup\_database  
$ rake

Please file a ticket about this and I will make sure it is fixed for the  
next release.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)
