1

我有一个 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'时 以前它运作良好。

我该如何摆脱它?

4

2 回答 2

0

它应该在 sinatra/padrino 支持gem 'kaminari', :require => 'kaminari/sinatra'的 kaminari README 部分中解释

于 2013-02-09T03:37:10.513 回答
0

实际上在内部需要的/lib/kaminari/helpers/sinatra_helpers.rb 文件第 128-129 行是

$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。

于 2013-02-09T09:25:24.303 回答