Ruby on rails 什么是正确的(现代)方式来要求一个宝石在另一个宝石?
我最近刚开始写我自己的珍宝。其中一个需要gnuplot gem,如下所示:Ruby on rails 什么是正确的(现代)方式来要求一个宝石在另一个宝石?,ruby-on-rails,ruby,rubygems,dependencies,Ruby On Rails,Ruby,Rubygems,Dependencies,我最近刚开始写我自己的珍宝。其中一个需要gnuplot gem,如下所示: module Rocker require "gnuplot" # ... module code here ... end 在我将gem添加到我的一个Rails项目的config/environment.rb之前,它工作得非常好。然后,将不会加载任何页面。我会遇到如下错误: MatriceShow中的类型错误 显示 app/views/matrices/_detail.html.erb 第13行出现时: 无法
module Rocker
require "gnuplot"
# ... module code here ...
end
在我将gem添加到我的一个Rails项目的config/environment.rb之前,它工作得非常好。然后,将不会加载任何页面。我会遇到如下错误:
MatriceShow中的类型错误
显示
app/views/matrices/_detail.html.erb
第13行出现时:
无法复制类
追踪还在继续,但毫无用处。我很清楚,gnuplot正在制造某种冲突
gems是否有与config/environment.rb等效的配置?我知道你不应该再在宝石里要求rubygems了。什么是使我的定制宝石可用的正确方法
是的,我想我可以在Rails应用程序中添加gnuplot作为依赖项,但是我的gem不会通过单元测试
已请求完整跟踪。首先,我使用的是acts_as_可注释插件,当需要gnuplot时,会出现一个错误:
$ script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3002
/home/jwoods/NetBeansProjects/crossval/vendor/rails/activerecord/lib/active_record/base.rb:1959:in `method_missing': undefined local variable or method `acts_as_commentable' for #<Class:0xb6889710> (NameError)
from /home/jwoods/NetBeansProjects/crossval/app/models/matrix.rb:98
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /usr/lib/ruby/1.8/gnuplot.rb:6
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /var/lib/gems/1.8/gems/rocker-0.1.2/lib/rocker.rb:10
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /home/jwoods/NetBeansProjects/crossval/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:208:in `load'
from /home/jwoods/NetBeansProjects/crossval/config/../vendor/rails/railties/lib/initializer.rb:307:in `load_gems'
from /home/jwoods/NetBeansProjects/crossval/config/../vendor/rails/railties/lib/initializer.rb:307:in `each'
from /home/jwoods/NetBeansProjects/crossval/config/../vendor/rails/railties/lib/initializer.rb:307:in `load_gems'
from /home/jwoods/NetBeansProjects/crossval/config/../vendor/rails/railties/lib/initializer.rb:164:in `process'
from /home/jwoods/NetBeansProjects/crossval/config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
from /home/jwoods/NetBeansProjects/crossval/config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
from /home/jwoods/NetBeansProjects/crossval/config/environment.rb:9
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /home/jwoods/NetBeansProjects/crossval/vendor/rails/railties/lib/commands/server.rb:84
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/server:11
还有这个:
ActionView::TemplateError (can't dup NilClass) on line #13 of app/views/matrices/_detail.html.erb:
10: <li class="submatrix_info">Submatrices
11: <ul>
12: <% matrix.children.each do |child| %>
13: <li><%= link_to child.id, matrix_path(child), :class => "submatrix_link" %><%= experiments_progress_bar(child) %></li>
14: <% end %>
15: </ul>
16: </li>
app/helpers/matrices_helper.rb:104:in `experiments_progress_bar'
app/views/matrices/_detail.html.erb:13
app/views/matrices/_detail.html.erb:12
app/views/matrices/show.html.erb:12
app/controllers/matrices_controller.rb:28:in `show'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (74.6ms)
Rendered rescues/_request_and_response (0.2ms)
Rendering rescues/layout (internal_server_error)
您在gem中将gnuplot指定为依赖项了吗?@jpartogi,我在gem Rakefile中将它指定为依赖项@罗杰德帕克,我已经包括了全部痕迹。
ActionView::TemplateError (can't dup NilClass) on line #13 of app/views/matrices/_detail.html.erb:
10: <li class="submatrix_info">Submatrices
11: <ul>
12: <% matrix.children.each do |child| %>
13: <li><%= link_to child.id, matrix_path(child), :class => "submatrix_link" %><%= experiments_progress_bar(child) %></li>
14: <% end %>
15: </ul>
16: </li>
app/helpers/matrices_helper.rb:104:in `experiments_progress_bar'
app/views/matrices/_detail.html.erb:13
app/views/matrices/_detail.html.erb:12
app/views/matrices/show.html.erb:12
app/controllers/matrices_controller.rb:28:in `show'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (74.6ms)
Rendered rescues/_request_and_response (0.2ms)
Rendering rescues/layout (internal_server_error)