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:
- addCourse(
- pattern="user/registration/register",
- handler="main",
- action="welcome"
- );
- 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...
- <cfscript>
- COLDBOX_CONFIG_FILE = "config/projectname.coldbox.xml";
- </cfscript>
Step 2
In your coldbox.xml file, when you declare the SES interceptor, set the appropriate file name for your routes.cfm file.
- <!-- USE SES -->
- <Interceptor class="coldbox.system.interceptors.ses">
- <Property name="configFile">config/projectname.routes.cfm</Property>
- </Interceptor>
DUH!!
Like I said, I'm a complete moron. Hopefully documenting my moronic behavior helps someone not be as moronic as me.
Latest Articles
- No recent entries.
Categories
- ColdBox (21) [RSS]
- ColdFusion (92) [RSS]
- Fusebox (3) [RSS]
- General (22) [RSS]
- jQuery (15) [RSS]
- Kalendar (1) [RSS]
- Linux (1) [RSS]
- Mura CMS (1) [RSS]
- Railo (1) [RSS]
- Rants (5) [RSS]
- Transfer (8) [RSS]
- Uni-Form Tag Library (36) [RSS]
Quick Links
Blogs I Read
Calendar
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
« Feb | ||||||
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.
On 6/17/09 at 8:58 PM, Aaron Greenlee said:
Your not alone... we've all done something similar. Did LM Laugh?
On 6/22/09 at 5:40 PM, Jose Galdamez said: