If $ is undefined, that means that either jQuery isn't included, or the JS libraries weren't included in the right order, which is important.
A possible reason would be if Cloudinary was included before jQuery was, where it should be the other way around.
Here's an example of a correct order:
Using the asset pipeline, you can do something like the following:
//= require jquery
//= require jquery_ujs
//= require cloudinary