I Am a Complete Moron

Posted on June 17, 2009 at 7:33 PM in ColdBox, ColdFusion

Ayep, you read the title right. Quite frankly, it totally sucks that I have been forced to come to that realization, but I suppose in the end, it is better that I realized it before it was too late.

I was working on a ColdBox application, and I needed to take a "real" handler/action and reroute it to a different one.

"Easy enough," I thought to myself. "I'll just add a hard-coded course to the routes.cfm and redirect it to where I need it to go."

So I pulled up the routes.cfm tab in CFE, and added the following:

  1. addCourse(
  2. pattern="user/registration/register",
  3. handler="main",
  4. action="welcome"
  5. );
  6. addCourse(":handler/:action/:id-numeric?");

Note that the first addCourse()'s pattern argument is hard-coded. No variables such as the ':handler' or ':action' in the second course. And, since it is declared prior to the generic course, it will be checked against first, so that the "real" handler/action will never fire (even though it does indeed exist).

Do a quick ?fwreinit=1 and everything is fine, right? Wrong. Crap, the real handler/action still fires. What on earth is wrong? Should I use an interceptor instead? WTH?

So, rather than actually troubleshoot, I decide to be lazy and ping my good friend Luis and ask him why it doesn't work. Naturally he replied with

"Ummm, it should definitely work just fine. It does for me."

And it was right as he began typing his reply that I realized that I indeed am a complete moron.

Now I'm sure that no one else has ever done this (wink, wink), but I suddenly realized that I was editing the wrong routes.cfm file. That's right, I was editing the routes.cfm file for one application, while meaning to edit it in a completely different application. Needless to say, the changes in behavior were not showing up in the application I was loading.

Sadly I was not yet done with the "I'm a complete moron" realizations for the day. So my next comment to Luis was something like...

"Hey, man, we need to make sure in ColdBox 3.0 to add the ability to name your coldbox.xml and/or routes.cfm files with some sort of project prefix so that idiots like me don't do what I just did."

And then Luis informed me that ColdBox, of course, already had that capability.

Step 1

In your Application.cfc, simply set the COLDBOX_CONFIG_FILE variable to whatever name you name it. In my case it looks like this...

  1. <cfscript>
  2. COLDBOX_CONFIG_FILE = "config/projectname.coldbox.xml";
  3. </cfscript>

Step 2

In your coldbox.xml file, when you declare the SES interceptor, set the appropriate file name for your routes.cfm file.

  1. <!-- USE SES -->
  2. <Interceptor class="coldbox.system.interceptors.ses">
  3. <Property name="configFile">config/projectname.routes.cfm</Property>
  4. </Interceptor>

DUH!!

Like I said, I'm a complete moron. Hopefully documenting my moronic behavior helps someone not be as moronic as me.

Comments
(Comment Moderation is enabled. Your comment will not appear until approved.)

On 6/17/09 at 8:58 PM, Aaron Greenlee said:

I've just started playing with it so I am no expert, but, it sounds like you can benefit from the Mylyn Plug-In for Eclipse.

Your not alone... we've all done something similar. Did LM Laugh?

On 6/22/09 at 5:40 PM, Jose Galdamez said:

Don't feel bad! This could have happened to anyone. We all learn a little bit more as the days go by.
CodeBassRadio

Latest Articles

Eventually something really brilliant and witty will appear right here.

Calendar

May 2022
S M T W T F S
« Apr  
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

Subscribe

Enter a valid email address.

The Obligatory Wish List