【问题标题】:Rails 3 Production Nil Error with javascript_include_tag带有javascript_include_tag的Rails 3 Production Nil错误
【发布时间】:2012-03-30 08:07:26
【问题描述】:

我目前正在尝试部署一个 rails 3.0.9 应用程序。该应用程序在我的开发盒(ruby 1.8.7 p352,mongrel)上运行良好,但在生产盒(ruby 1.8.7 p334,Passenger)上产生以下错误。

A ActionView::Template::Error occurred in site#index:
 can't convert nil into String
 vendor/bundle/ruby/1.8/gems/actionpack-3.0.9/lib/action_view/helpers/asset_tag_helper.rb:888:in `read'

堆栈跟踪是:

vendor/bundle/ruby/1.8/gems/actionpack-3.0.9/lib/action_view/helpers/asset_tag_helper.rb:888:in `read'
vendor/bundle/ruby/1.8/gems/actionpack-3.0.9/lib/action_view/helpers/asset_tag_helper.rb:888:in `join_asset_file_contents'
vendor/bundle/ruby/1.8/gems/actionpack-3.0.9/lib/action_view/helpers/asset_tag_helper.rb:888:in `collect'
vendor/bundle/ruby/1.8/gems/actionpack-3.0.9/lib/action_view/helpers/asset_tag_helper.rb:888:in `join_asset_file_contents'
vendor/bundle/ruby/1.8/gems/actionpack-3.0.9/lib/action_view/helpers/asset_tag_helper.rb:894:in `write_asset_file_contents'
vendor/bundle/ruby/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/file/atomic.rb:20:in `atomic_write'
vendor/bundle/ruby/1.8/gems/actionpack-3.0.9/lib/action_view/helpers/asset_tag_helper.rb:894:in `write_asset_file_contents'
vendor/bundle/ruby/1.8/gems/actionpack-3.0.9/lib/action_view/helpers/asset_tag_helper.rb:356:in `javascript_include_tag'
app/views/layouts/application.html.erb:79:in `_app_views_layouts_application_html_erb___689799961_85527100_0'

application.html.erb 的第 79 行是:

<%= javascript_include_tag (Rails.env.development? ? "jquery.min.js" :  "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"),
                         "jquery-ui.min",
                         "application", :cache => true %>

我尝试从 javascript_include_Tag 中删除条件,但这没有任何区别

【问题讨论】:

    标签: javascript ruby-on-rails ruby-on-rails-3 assets


    【解决方案1】:

    如果所有参数实际上都是服务器上的文件,则只能使用 :cache=&gt;true 选项 - rails 不会为您从 googleapis 获取 jquery(如果这样做,它宁愿失败)

    将 jquery.min.js 包含在它自己的 javascript_include_tag 中,没有 :cache 选项,你应该没问题。或者,您可以停止尝试从 googleapis 加载 jquery。

    【讨论】:

      猜你喜欢
      • 2015-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-30
      • 1970-01-01
      • 2021-07-11
      • 1970-01-01
      • 2021-04-06
      相关资源
      最近更新 更多