我有一个Sinatra应用程序。添加gem 'kaminari'
后,我开始收到错误
/var/lib/gems/1.9.1/gems/backports-2.7.1/lib/backports/tools.rb:318:in `require': cannot load such file -- rails (LoadError)
from /var/lib/gems/1.9.1/gems/backports-2.7.1/lib/backports/tools.rb:318:in `require_with_backports'
from /var/lib/gems/1.9.1/gems/kaminari-0.11.0/lib/kaminari/railtie.rb:1:in `<top (required)>'
from /var/lib/gems/1.9.1/gems/backports-2.7.1/lib/backports/tools.rb:318:in `require'
from /var/lib/gems/1.9.1/gems/backports-2.7.1/lib/backports/tools.rb:318:in `require_with_backports'
from /var/lib/gems/1.9.1/gems/kaminari-0.11.0/lib/kaminari.rb:2:in `<top (required)>'
from /var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
from /var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
from /var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
from /var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
from /var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
from /var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
from /home/alex/Documents/ruby_projects/app_base.rb:3:in `<top (required)>'
from /home/alex/Documents/ruby_projects/app.rb:1:in `require_relative'
from /home/alex/Documents/ruby_projects/app.rb:1:in `<top (required)>'
from /home/alex/Documents/ruby_projects/config.ru:11:in `require'
from /home/alex/Documents/ruby_projects/config.ru:11:in `block in <main>'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:55:in `instance_eval'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:55:in `initialize'
from /home/alex/Documents/ruby_projects/config.ru:in `new'
from /home/alex/Documents/ruby_projects/config.ru:in `<main>'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:49:in `eval'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:49:in `new_from_string'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:40:in `parse_file'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:199:in `app'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:314:in `wrapped_app'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:250:in `start'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:141:in `start'
from /var/lib/gems/1.9.1/gems/rack-1.5.1/bin/rackup:4:in `<top (required)>'
from /usr/local/bin/rackup:23:in `load'
from /usr/local/bin/rackup:23:in `<main>'
当我尝试通过'rackup'
启动应用程序时。以前它运作良好。
我如何摆脱它?
答案 0 :(得分:0)
应gem 'kaminari', :require => 'kaminari/sinatra'
答案 1 :(得分:0)
实际上是内部要求/lib/kaminari/helpers/sinatra_helpers.rb
file lines 128-129 are:
$stderr.puts "[!]You should install `padrino-helpers' gem if you want to use kaminari's pagination helpers with Sinatra."
$stderr.puts "[!]Kaminari::Helpers::SinatraHelper does nothing now..."
所以我认为你应该安装padrino-helpers。