Tuesday, October 11, 2011

A Vague JQuery Template Error

I have been getting an error in JQuery Template, and it's one of those errors that is impossible to debug. It's an issue that can only be fixed by intricately checking your code line by line, character by character. Here is the vague error that I'm getting:
Uncaught SyntaxError: Unexpected token return
Actually, here is the full "stack trace" (if that's what you want to call it) of the error:

I get no js compiler errors or anything, I just get this javascript error when I click on a radio button, but nothing more. My page loads correctly with no problem otherwise. Because of this fact, I was forced to inspect my code over and over and over and over... I removed code, I added code. I reworked my html a few times as well, but still got the error every time. I was literally going in circles trying everything.

The problem? I had an extra jQuery template tag in the very bottom of my script like this:


At one point I tried combining both states into a single template using {{if}} {{else}} {{/if}}, but then gave up on that idea... Clearly I missed the closing tag and then never bothered to look at the bottom of my script tag when things didn't work. I'ts kind of insane that so much time was wasted on such a silly oversight on my part... Oh the whoa's of a programmer. Back to the grind.

Wednesday, October 05, 2011

Ruby On Rails Fan

OK, so I've been going through the online Ruby On Rails Tutorial by Michael Hartl for the last few weeks in my spare time, and I'm a better programmer because of it. I've not taken any shortcuts and have learned quite a lot. The whole Model / View / Controller aspect of it came pretty easy to me since I'm a full-time ASP.NET MVC developer in my day job. Server side tags, module level variables, and helper modules are shared concepts from the ASP.NET MVC world (which I think they stole from RoR, but...). I'm really liking my new hobby.

I've learned quite a few tricks that make Ruby on Rails much more pleasing to work with than ASP.NET MVC. Namely, I like the built-in gem utilities (package manager for Ruby on Rails), I also like the command line utilities for defining database schemas, generating test records, and auto generating oodles of code. There are so many gems that work together to support testing controllers, models, and views on the fly as you code. I always thought of Unit Testing as a good thing, but it always felt like I was forcing myself to learn / practice TDD. I just never quite "got it"; when I would write unit tests I felt good about it, but as new features come into my project it is very easy to just code my projects without writing unit tests for every little thing. With Ruby on Rails, however, it feels very natural and is almost required due to the dynamic nature of the language. RSpec makes creating tests a breeze.

I'm currently hosting a few Ruby on Rails projects on Heroku, and even doing this is brain-dead easy. I literally auto-generated a Rails project from the command line, and then used the Heroku gem to "git push" my code to Heroku. It does the rest and builds my project and deploys it for the world to see.

Just the other night, I bought a domain and plan to run my very own Ruby on Rails project... I won't give away the domain name yet, but know that I'll be making a big deal of it within the next few months. In short, I love Ruby on Rails and everything that goes with it, including Vim (with rails.vim), Git, Autotest (with Growl), Spork, TDD, and everything else). I can now say that I'm a ASP.NET MVC developer by day / Ruby on Rails developer by night.


Tuesday, October 04, 2011

Testing the 'A' key

I came up with this while trying to test if I still had static electricity inside my board:
an alpha alligator almost ate annies apples after alfred asked again and again.
Figured I'd share it in case anybody else needs to test their 'a' key. :) Truthfully, I made it up on the fly, and impressed myself so much that I had to share it.