filename should be app/assets/javascripts/application/views/attachments/preview.js

application indicates it's part of the application.js (ie. frontend). It's file name / path should exactly mirror the template / partial it's consumed by.