2010-01-25 95 views
1

我最近安装了集成3.0版本的Bundle gem(stable 2.3.x)。安装2.3.x的文档很薄弱,所以我在这里寻求帮助。Rails Gem Bundler破坏依赖关系

我已经安装和配置宝石打捆(安装宝石打捆,定义的Gemfile,加入preinitializer.rb,需要bundler_gems/environment.rb中)所做的一切都是从这篇文章:

http://litanyagainstfear.com/blog/2009/10/14/gem-bundler-is-the-future/

我可以成功运行脚本/服务器,但是当我试着通过浏览器访问的任何页面,我得到一个500内部服务器错误,声称许多使用的ActionView方法是不确定的:

ActionView::TemplateError (undefined method `debug' ... 

ActionView::TemplateError (undefined method `javascript_tag' ... 

必须有一些宝石依赖在某处或某事失败了吗?这里是我的Gemfile(导轨2.3.5):

clear_sources 
bundle_path "vendor/bundler_gems" 

source "http://gems.github.com" 
source "http://gemcutter.org" 

gem "rails", "2.3.5" 
gem "formtastic" 
gem "authlogic" 
gem "will_paginate" 
gem "cancan" 

任何指针?

+0

所述捆绑文档是可怕的。 – Jonathan 2010-02-02 16:06:56

回答

1

所以对于on Rails的2.3.5配置创业板捆绑:

我改变了我的preinitializer.rb脚本这样:

# Load the environment constructed from the Gemfile 
require "#{File.dirname(__FILE__)}/../vendor/bundler_gems/environment" 

module Rails 
    class Boot 
    def run 
     load_initializer 
     extend_environment 
     Rails::Initializer.run(:set_load_path) 
    end 

    def extend_environment 
     Rails::Initializer.class_eval do 
     old_load = instance_method(:load_gems) 
     define_method(:load_gems) do 
      old_load.bind(self).call 
      Bundler.require_env RAILS_ENV 
     end 
     end 
    end 
    end 
end 

并已删除到config/environment.rb任何Bundler.require_env定义,一切都很好。

http://gist.github.com/286099

+0

这看起来可能有用,但它很复杂。在后面的阶段调用'Bundler.require_env'也是可行的,不需要在'load_gems'步骤完全插入。 – mislav 2010-01-25 19:38:25

+0

这对我有效(不知道为什么,但不抱怨)。我也开始得到'config.gem:供应商/ gems中的解压缩gem environment.rb没有规范文件。运行'耙宝石:refresh_specs'来解决这个问题。'错误 - 保存忽略这些? – Jonathan 2010-02-02 16:06:20

+0

嗯,这也发生在我身上。你可以尝试只运行任务,如果还是不行,别人贴出了破解: http://stackoverflow.com/questions/2144659/how-to-silence-gem-errors-after-switching-捆绑销售 但我认为有一个更聪明的方法来解决它。也许只是尝试删除您的Gemfile,然后重新创建并再次运行“Gem Bundle”。呃... – ajhit406 2010-02-03 17:24:20

0
这些宝石

大部分(或全部)的Rails插件。您应该在Rails初始化阶段要求他们。将其粘贴在你的after_initialize

config.after_initialize do 
    Bundler.require_env 
end 
+0

什么是最好的文件,把该snipit?谢谢! – Jonathan 2010-02-02 15:47:14