ruby – 使用s3 gem rails 4.1.5时,不允许使用`@@ {‘作为类变量名(SyntaxError)

前端之家收集整理的这篇文章主要介绍了ruby – 使用s3 gem rails 4.1.5时,不允许使用`@@ {‘作为类变量名(SyntaxError)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道这类问题已经被问到了.

我使用s3 gem在s3存储桶中上传我的文件.但是在s3 gem安装之后,当我启动rails服务器时它会显示以下错误

/var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223:in `class_eval': /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223: `@@{' is not allowed as a class variable name (SyntaxError)
/var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223: Syntax error,unexpected $end
        unless defined? @@{:instance_writer=>true}
                          ^
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223:in `block in cattr_reader'
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:222:in `each'
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:222:in `cattr_reader'
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:258:in `cattr_accessor'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:155:in `<class:Store>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:154:in `<module:Cache>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:14:in `<module:ActiveSupport>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:12:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/jbuilder-2.2.5/lib/jbuilder/jbuilder_template.rb:3:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/jbuilder-2.2.5/lib/jbuilder/railtie.rb:2:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/jbuilder-2.2.5/lib/jbuilder.rb:317:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
    from /home/rick/rick/Projects/practice/shareBox/config/application.rb:7:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:in `require'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:in `block in server'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `server'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

有谁知道,如何解决这个错误?我应该尝试另一颗宝石吗?

解决方法

是的,我刚刚遇到这个问题并解决了.这是因为AWS将他们的gem更新为2.0.如果您将gem更新为2.0,则需要根据此 article发布不同的配置.

如果你想使用以前的版本,只需更改Gemfile如下:

的Gemfile

gem’aws-sdk’,’< 2.0'

猜你在找的Ruby相关文章