4

I user Rails 4 and Cocoon gem. In fact, I know the problem - cocoon.js is not compiled into application.js as I can see in the browser. I do require cocoon in application.js and have the gem installed.

I do not use turbolinks. What else might cause this?

  • `I know the problem - cocoon.js is not compiled into application.js as I can see in the browser`, In production or development? – BroiSatse Mar 03 '16 at 15:20
  • Production, assets served via Nginx –  Mar 03 '16 at 15:24
  • Have you recompiled your assets before deploying? How do you deploy? – BroiSatse Mar 03 '16 at 15:28
  • I have nginx docker container serve /app/assets/*. It's surprising for me, since other JS libraries do work ok. –  Mar 03 '16 at 19:59
  • 1
    You should never serve directly from your `/app/assets` folder - this is only for development. You should always precompile your assets and serve `/public` folder instead. – BroiSatse Mar 03 '16 at 20:21
  • Ok, noted. Still does not answer the question why other JS libs are working ok and compiled into application.js and cocoon is not. –  Mar 06 '16 at 19:38
  • I am really surprised that anything got compiled into application.js - that is a result of precompilation process. Is your website available publicly? If so, could you give the link? – BroiSatse Mar 06 '16 at 20:06
  • No, it's not public. I've turned precompilation on. Now I have cocoon with digest compiled to /public/assets. I have it accessible via Nginx. But clicking on add_association doe s not call anything. –  Mar 06 '16 at 20:15
  • Accessible via nginx is not the same as available in your application. Does the script actually get requested by the browser when the page loads? – David John Smith Mar 06 '16 at 23:26
  • @BroiSatse - thnx, was my bad w/ nginx configuration. –  Mar 12 '16 at 11:13
  • please post as answer –  Mar 12 '16 at 11:14

1 Answers1

1

I got this answer from the developer of cocoon.

Good news! Tips for the future: do not do rake assets:precompile in development, because I have noticed weird effects with that too. And to really clean the assets, you have to do rake assets:clobber (clean leaves the last three compilations and deletes the older ones).

I hope it helps.

Adebayo
  • 331
  • 2
  • 12