Rails 3.1 - sharing precompiled assets across servers
App 1 is on server A. App 2 is on server B.
App 2 has precompiled assets and everything works great.
Now App 1 wants to use the same CSS file as App 2 that resides on server B.
Is there a way to make this work?
I tried setting:
config.action_controller.asset_host = "http://assets.example.com"
in App 1 but that didn't seem to help.
When I view an image on App 2 the path shows the url with the cache fingerprint like assets/logo-i3q73498g0.png where-as 开发者_StackOverflow社区in App 1 where the image isn't showing, the path is just logo.png
Thanks!
The answer to this is probably to share the assets manifest file between apps. This file contains mappings for raw filenames to the ones with fingerprints in them.
This is at public/assets/manifest.yml by default. I suggest that when you deploy App 2 you add a task to grab the asset manifest from App 1, and assuming that App 2 does not have any compiled assets (because you have changed the host) just use that for the app. You would have to set the config to make App 2 think it has compiled assets.
精彩评论