Monthly Archives: February 2014

Angularjs and Grails withFormat and json

I have been doing a mixed angularjs and grails project and ran into problems getting json to come back from the controller request with a withFormat block.

What I expected

I expected that it would call the grails app controller index method and with the withFormat to pick out that the request came is as a json request so return json. This is not the case, it would send me back the html page instead.

The problem was that grails would see */* as the accept headers and return just the html.

Grails code from the grails controller

def index() {
        def books = Book.findAll().collectEntries { book -> [book.title, book] }.values()
        withFormat {
            html books: books
            json { render books as JSON }

Angularjs json request that returns html

$http.get('/book/index').success(function(response) { };

Continue reading

Yeoman migration to 1.0 and grunt with coffeescript

With migrating to yeoman 1.0 from version 0.9.6 you have to essentially create a new project and import your source over as the builds have changed so much.  Check the documentation from yeoman on how to do the upgrade.

I have an Angularjs project with coffeescript that I wanted to have compile to individual js files. There are lots of good examples on how grunt works with coffeescript from the source

Purpose of compiling coffeescript this way.

This will create 1 js file per coffee file and have them sit next to the original source coffeescript file.  This is not what you want to release to production as there are a lot of network requests per page.

Continue reading

Synology NAS blinking orange light and no hard drive lights

I started to get a orange blinking light and the hard drive lights were not coming on for my synology NAS drive.

I had tried to add another old backup to the usb ports in the back.

After much searching and trying to reinstall the entire DSM.

This gave me a Error 38 could not find the NAS to install upon.

The hard drives had come dislodged at some point.  After reinserting them again it is back working properly.

There is a design fault where you cannot lock the drives into place so they can come dislodged if you hold the unit the wrong way, or shake the unit.