Does local assets precompilation cause a problem for server side rendering a component?
I got strange error. My scenario is:
- I have an app locally with react component with prerender: true. In development and production environments it works fine.
- 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”
- This problem appeared when I turn compilation assets to local machine. When it compiles on server it works fine
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:
- clean public/assets dir locally - I didn’t run assets:clobber cause I’m on Rails 3
- run deploy to the staging server. Notice that on assets compile step I just copy local compiled assets to the server via rsync
- 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.