如何检测rails项目中的gem使用情况?

时间:2012-07-10 22:16:12

标签: ruby-on-rails ruby-on-rails-3 rubygems bundler inherited-resources

我想在Inherited Resources中启用对Opinio gem gem的支持,但我需要检测项目中是否使用了Inherited Resources。

我查看了Bundler的文档以找到有关gem使用检测的内容,但我什么都没发现。你能推荐一下吗?

1 个答案:

答案 0 :(得分:1)

您可以测试InheritedResources gem的模块是否存在。

begin
  Module.const_get('InheritedResources')
  # made it here? InheritedResources is included
rescue NameError => e
  # InheritedResources is not included
end