0

按照http://rubygems.org/gems/mobile-fu上的说明安装 gem (“只需添加gem 'mobile-fu'到您的 Gemfile 并运行 bundle install”)工作正常,并且 gem 被列为已安装并且所有需要的依赖项也在放置AFAIK,下面是项目Gemfile的相关部分:

source :gemcutter
source 'http://gems.github.com'

gem 'rails', '~> 2.3.14'
gem 'aslakjo-comatose', '2.0.5.12', :require => 'comatose'
gem 'adamwiggins-rest-client', '1.0.4'
gem 'ruby-hmac', '0.4', :require => 'hmac'
gem 'ruby-net-ldap', '0.0.4', :require => 'net/ldap'
gem 'will_paginate', '2.3.11'
gem 'hpricot', '0.8.2'
gem 'oauth', '0.3.6'
gem 'sanitize', '1.1.0'
gem 'sunspot_rails', '1.1.0', :require => 'sunspot/rails'
gem 'htmlentities'
gem 'rdoc', :require => 'rdoc'
gem 'to_xls'
gem 'pusher'
gem 'jammit'
gem 'rabl', '~>0.6'
gem 'paperclip', '~> 2.7'
gem 'aws-sdk', '~> 1.3.4'
gem 'mobile-fu', '~> 1.1.0'
...

这是启动服务器时产生的错误消息/日志:“没有要加载的此类文件--mobile / fu(MissingSourceFile)”是主要问题(恕我直言):

=> Booting WEBrick
=> Rails 2.3.14 application starting on http://0.0.0.0:3000
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21.
/home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:74:in `require': no such file to load -- mobile/fu (MissingSourceFile)
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:74:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
    from /home/work/web/srv/config/boot.rb:116:in `load_gems'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/initializer.rb:164:in `process'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/initializer.rb:113:in `send'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/initializer.rb:113:in `run'
    from ./config/environment.rb:7
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
    from /home/work/web/srv/config.ru:1
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rack-1.1.3/lib/rack/builder.rb:46:in `instance_eval'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rack-1.1.3/lib/rack/builder.rb:46:in `initialize'
    from /home/work/web/srv/config.ru:1:in `new'
    from /home/work/web/srv/config.ru:1
    from ./script/server:3:in `eval'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/commands/server.rb:78
    from ./script/server:3:in `require'
    from ./script/server:3

更新 1

使用 Ben Langfeld 描述的解决方案(“您可以在 Gemfile 中使用以下内容解决此问题:gem 'mobile-fu', '~> 1.1.0', :require => 'mobile-fu'”)只会产生如下所示的新错误:

=> Booting WEBrick
=> Rails 2.3.14 application starting on http://0.0.0.0:3000
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21.
/home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require': no such file to load -- rails (MissingSourceFile)
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/mobile-fu-1.1.0/lib/mobile-fu.rb:1
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
    from /home/work/web/srv/config/boot.rb:116:in `load_gems'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/initializer.rb:164:in `process'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/initializer.rb:113:in `send'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/initializer.rb:113:in `run'
    from ./config/environment.rb:7
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
    from /home/work/web/srv/config.ru:1
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rack-1.1.3/lib/rack/builder.rb:46:in `instance_eval'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rack-1.1.3/lib/rack/builder.rb:46:in `initialize'
    from /home/work/web/srv/config.ru:1:in `new'
    from /home/work/web/srv/config.ru:1
    from ./script/server:3:in `eval'
    from /home/work/.rvm/gems/ruby-1.8.7-head@srv/gems/rails-2.3.14/lib/commands/server.rb:78
    from ./script/server:3:in `require'
    from ./script/server:3

没有为此 gem 列出的 ruby​​ 或 rails 的最低版本,但我怀疑问题是由我们正在运行的旧版本引起的。但是,升级 ruby​​ 或 rails 不是一种选择,因为这是一个维护项目。

如果存在任何已知可在我们的 ruby​​ 和 rails 版本/配置上运行的具有类似功能的 Mobile Fu 替代 gem,如果无法解决此问题,我们愿意研究该替代选项。

4

2 回答 2

0

您可以在 Gemfile 中使用以下内容解决此问题:

gem 'mobile-fu', '~> 1.1.0', :require => 'mobile-fu'
于 2012-11-06T15:31:04.820 回答
0

由于 Mobile Fu gem 与 ruby​​ 1.8.x / rails 2.3.x 不兼容,我们最终根据以下文章创建了自己的类似功能:http: //erniemiller.org/2011/01/05/mobile-devices -and-rails-maintaining-your-sanity/

于 2012-11-15T09:38:53.490 回答