开发者

How do I keep static assets from a bundled gem in-sync in my Rails 2.3 app?

开发者 https://www.devze.com 2023-01-30 04:06 出处:网络
I am working on a Rails 2.3 application and would like to refactor some of my static assets (JS, CSS) into a separate gem. The problem is that Rails 2.3 engines don\'t have the support for public dire

I am working on a Rails 2.3 application and would like to refactor some of my static assets (JS, CSS) into a separate gem. The problem is that Rails 2.3 engines don't have the support for public directories that Rails 3 engines do, so the only way to access these files from the app is to copy them over.

One thought I had was to use some sort of "afterBundle" hook of so开发者_Python百科me sort that I could use to automatically copy the assets after "bundle install" completes. I took a look at Bundler's documentation and source and didn't find anything like what I'm thinking. How have others solved this problem?


One issue in using Bundler is that there are now two install paths for you gem, gem install and bundle install. Even if you do hack a Bundler post install action to Bundler it won't run if some one does gem install. One solution is to make the gemspec relatively empty, example:

https://github.com/hedgehog/fog/blob/bundler/fog.gemspec

Then simulate a post install hook for gem install, which in fact invokes bundle install:

https://github.com/hedgehog/fog/commit/32878aaa9ef1fd3add148039fecd6e4059873d5d

With this work around you can add your post install actions after bundle install is run.

However, by adding the post install steps to gem install you have re-introduced the opening problem - two different install paths, just that now gem install does more (the post install steps) than bundle install does.

See also: http://blog.costan.us/2008/11/post-install-post-update-scripts-for.html

0

精彩评论

暂无评论...
验证码 换一张
取 消