Kyle Banks

Filed Under #grails

A lot of times when starting a new Grails project (or any new project, for that matter), there is a lot of work done on user authentication and registration, role definition and permissions, and managing the authentication flow.
Something that I recently needed to add for the admin panel and home page of this site's redesign was to order posts by the number of views it has. I was actually quite surprised to find that Grails doesn't inject this functionality as part of it's standard CRUD functions on domain classes, such as list and findByXAndY.
Implementing a custom 404 page can be an effective way to retain visits from people who have found a dead link to your site, or have stumbled upon a page that doesn't exist. Depending on the content of the URL, you may even be able to show the vistor some links they may be interested in based on related content.
GORM provides Grails developers with plenty of useful hooks, events, methods, and functionality, not the least of which is domain events that inform you when domain objects are being created, updated, and deleted (you can find documentation on these events here). Within these events, a common use-case is to determine if a particular domain property has changed, and to act accordingly.
It seems that ever since Grails 2.1 arrived, controller classes have not been auto-reloaded when edited in a development environment. I'm not sure if this is now the intended behaviour of controllers, but it sure can make for slower development and debugging.
With all of the news about Google shutting down Reader on July 1st, there seems to be an uprising of new RSS feed readers cropping up to try and fill the void.
Having the same content available at www.yourdomain.com and yourdomain.com is bad for SEO, because it counts as duplicate content. Not allowing users to go to www or root is even worse, as most users will simply assume the website is broken, or nonexistent. The solution is to redirect from one to the other, allowing users to go to whichever they prefer, and removing the issue of duplicate content. I prefer to redirect from www to...
One of my favourite features of Grails is the ability to render just about any object as JSON. This makes the creation of REST API calls a breeze, but one problem with the default implementation is that it renders the entire object as JSON. This isn't always an issue, but if for example you are rendering a User object, you (hopefully) don't want to output the user's password. You may also wish to limit the...

Hello, World!

Feb 18, 2013
Welcome to my new site. If you ever took the time to look at the old site, first of all thank you, secondly you will know it was severely lacking. The design was mediocre at best, and it was all very static. I wanted to start getting into blogging again, and not just use this space to showcase some of my work.