0

祝大家新年快乐,万事如意。

我已经开始学习 ROR 并尝试用它创建我的第一个应用程序。我正在尝试使用 Twitter 引导 gem。捆绑安装后,当我尝试运行 rails server 命令时,出现此错误:

/var/lib/gems/1.8/gems/twitter-bootstrap-rails-2.1.9/lib/twitter/bootstrap/rails/engine.rb:3:in `require': /var/lib/gems/1.8/gems/twitter-bootstrap-rails-2.1.9/lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb:33: syntax error, unexpected ':', expecting kEND (SyntaxError)

有人可以指导我在这里缺少什么吗?

这是相同的堆栈跟踪:

/var/lib/gems/1.8/gems/twitter-bootstrap-rails-2.1.9/lib/twitter/bootstrap/rails/engine.rb:3:in `require': /var/lib/gems/1.8/gems/twitter-bootstrap-rails-2.1.9/lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb:33: syntax error, unexpected ':', expecting kEND (SyntaxError)
    I18n.t name, scope: scope
                       ^
from /var/lib/gems/1.8/gems/twitter-bootstrap-rails-2.1.9/lib/twitter/bootstrap/rails/engine.rb:3
from /var/lib/gems/1.8/gems/twitter-bootstrap-rails-2.1.9/lib/twitter-bootstrap-rails.rb:4:in `require'
from /var/lib/gems/1.8/gems/twitter-bootstrap-rails-2.1.9/lib/twitter-bootstrap-rails.rb:4
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
from /var/www/ahex_connect/config/application.rb:7
from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/commands.rb:53:in `require'
from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/commands.rb:53
from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/commands.rb:50:in `tap'
from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/commands.rb:50
from script/rails:6:in `require'
from script/rails:6
4

1 回答 1

3

问题是您使用的是 Ruby 1.8,而第 33 行(twitter-bootstrap-railsgem 内)的语法来自 Ruby 1.9。他们已经修复了这个问题,使其兼容master. 所以可能的解决方案:

  1. 将您的 Ruby 版本升级到 1.9。
  2. 使用 git 版本的 gem。将其放入 Gemfile(修改现有行)并运行bundle install

    gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'

于 2013-01-02T10:09:43.163 回答