按照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不是一种选择,因为这是一个维护项目。
如果存在具有类似功能的Mobile Fu的替代宝石,则可以使用我们的ruby& rails version / config,如果无法解决此问题,我们愿意考虑备用选项。
答案 0 :(得分:0)
您可以使用Gemfile中的以下内容解决此问题:
gem 'mobile-fu', '~> 1.1.0', :require => 'mobile-fu'
答案 1 :(得分: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/