Local asset compilation and server side rendering problems

Hello everybody!

Does local assets precompilation cause a problem for server side rendering a component?

I got strange error. My scenario is:

  1. I have an app locally with react component with prerender: true. In development and production environments it works fine.
  2. When deploy my app to the server I got an error
    ActionView::Template::Error (ERROR in SERVER PRERENDERING
    Encountered error: “ReferenceError: ReactOnRails is not defined”
  3. This problem appeared when I turn compilation assets to local machine. When it compiles on server it works fine

Any thoughts?

You probably need to clear out your public /public/assets folder with rake assets:clobber. Generally, you should ONLY run rake assets:compile if you are locally testing your production deploy and then you need to REMEMBER to do the clobber!

What you mean by “Remember to do the clobber”? Im deploying app with capistrano and only one difference from default deploy case is compiling assets locally and pushing it to the server. You mean I have to run rake assets:clobber after rake assets:compile but before rsync it to server? Right?

You only need to remember to clobber when you’re testing locally.

I’ve given a shot - doesn’t help. Following steps I made:

  1. clean public/assets dir locally - I didn’t run assets:clobber cause I’m on Rails 3
  2. run deploy to the staging server. Notice that on assets compile step I just copy local compiled assets to the server via rsync
  3. I get an error react_on_rails undefined - only if prerender: true - if it false everything works great and no errors in console

Cleaning assets before precompilation doesn’t make sense. Any suggestions?

@ignasio.dpk, sounds like this will require some yak shaving.

Feel free to email me directly if you want personalized help.