use jbuilder for json output, use route constraints instead of if/else in controller