work from Ryan Bates' Railscasts tutorials