Ruby版本的Rails和activesupport-3.2.12的困难

时间:2013-03-03 23:34:08

标签: ruby-on-rails ruby-on-rails-3 rubygems ruby-on-rails-3.2 ubuntu-12.04

我有一个在我的测试环境中构建的rails应用程序。

ruby -v  => 1.9.3p194    
rails -v => 3.2.12    
gem -v   => 1.8.23

在我希望部署到的服务器上,输出如下:

ruby -v  => 1.9.3p0
rails -v => 3.2.12
gem -v   => 1.8.15

我已经开始全新安装服务器,但我无法获得ruby和gem的服务器版本。

另外,当我在服务器上运行rails s(只是为了测试)时,这是失败的输出:

rails s
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load': /var/www/New/confed ':', expecting kEND (SyntaxError)
  match '/about',   to: 'static_pages#about'
                       ^
/var/www/New/config/routes.rb:6: syntax error, unexpected ':', expecting kEND
  match '/cv',          to: 'static_pages#cv'
                           ^
        from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
        from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
        from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `load_paths'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `each'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `load_paths'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:16:in `reload!'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:26:in `updater'
        from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:in `call'
        from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:in `execute'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:27:in `updater'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/finisher.rb:66
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `run_initializers'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `send'
        from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /var/www/New/config/environment.rb:5
        from /var/www/New/config.ru:3:in `require'
        from /var/www/New/config.ru:3
        from /var/lib/gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
        from /var/lib/gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
        from /var/www/New/config.ru:0:in `new'
        from /var/www/New/config.ru:0

我查看了我的测试系统而我没有/var/lib/gems/1.8我只有/var/lib/gems/1.9.1

1 个答案:

答案 0 :(得分:2)

从堆栈跟踪中,它实际上看起来像是在针对Ruby 1.8运行,它不支持简化的哈希语法symbol: value,而1.8只有:symbol => value

您可以使用rvmrbenv来管理多个ruby版本。在使用Rails时,rbenv imo是两者中最好的。

<小时/> 回答Ryan关于我为什么认为rbenv > rvm基于个人感受的问题。我发现rbenv易于使用,易于理解并概念化它是如何工作的,而且我还没有遇到过让我失望的情景。此外,源代码非常易读,这让我很容易进行配置。