开发者

Declaring In-Line Secret Keys in Ruby On Rails

I'm learning Ruby On Rails. I'm trying to use the aws-s3 gem to access Amazon S3. One line of my controller code reads:

AWS::S3::Base.establish_connection!(
      :access_key_id     => 'myrealaccesskeyishere',
      :secret_access_key => 'myrealsecretkeyishere'
)

I've noticed that if I make an error, sometimes rails will come back and show a few lines of code where it thinks the error might be. Shoul开发者_如何学Cd I not be writing these out in the .rb controller files like this? Am I potentially risking my secret key? If so, how should I be doing this instead?


You should put this in an initializer. Place it in config/intializers/amazon_s3.rb

Is there a reason you are putting this code directly in the controller?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜