ROR,AMAZONS3,语法错误

时间:2015-08-21 13:03:05

标签: ruby-on-rails amazon-s3

当我尝试生成控制器时,我收到此错误消息 ' rails g controller歌曲索引上传删除' 我为establish_connection部分输入了id和密码。

/Users/owner/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:82:in `require': /Users/owner/Desktop/projects/musicapp/config/application.rb:19: syntax error, unexpected tSYMBEG, expecting ')'
      :secret_access_key => "mypassword"
       ^
/Users/owner/Desktop/projects/musicapp/config/application.rb:20: syntax error, unexpected ')', expecting keyword_end (SyntaxError)
    from /Users/owner/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:82:in `preload'
    from /Users/owner/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve'
    from /Users/owner/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
    from /Users/owner/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
    from /Users/owner/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
    from /Users/owner/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /Users/owner/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/owner/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'

application.rb文件

require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(:default, Rails.env) if defined?(Bundler)

module Mp3app
  class Application < Rails::Application
    config.encoding = "utf-8"
    config.filter_parameters += [:password]
    AWS::S3::Base.establish_connection!(
      :access_key_id     => 'Put your Access Key ID Here',
      :secret_access_key => 'Put your Secred Access Key here'
    )

    BUCKET = 's3tutorialmusic'

  end
end

1 个答案:

答案 0 :(得分:0)

我刚尝试过,它运行正常。

很可能你有旧的Ruby(1.9.3?),请尝试升级到2.2.x或者尝试这样:

AWS::S3::Base.establish_connection!({
      :access_key_id     => 'Put your Access Key ID Here',
      :secret_access_key => 'Put your Secred Access Key here'}
    )