开发者

How to bundle a gem in Rails?

HELP!! I need to bundle a gem otherwise a published cli开发者_运维百科ent's site will stay dead

    MacBook-Pros-MacBook-Pro:pn 
macbookpro$ sudo ruby script/generate sanitize
Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.


You could manually install the gem on the machine as the message tells you to, but since you're asking how to bundle the gem, that's probably not what you're looking for.

To bundle the Rails gems run the following on a machine that has the gems installed (probably your development machine):

rake rails:freeze:gems

This will unpack the Rails gems into vendor/rails. Then it's a matter of adding and commiting the gems.

To freeze/vendor all the gems required by your application (as defined in environment.rb):

rake gems:unpack:dependencies

If you use gems like Nokogiri that contains code which needs to be compiled for the environment it's running on, you have to a little more. After vendoring it, run

rake gems:build

and that should do it for you. Note, this last step needs to be run on the machine where the application needs to be run - in this case you can't just rely on doing it locally and committing your changes like you can with pure Ruby gems.

See http://reborg.tumblr.com/post/99668398/rails-gems-unpack-native for more details.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜