The safest way is to specify them as environment variables, so they are not included in your source code. If you are the only one who has access to the source, then specifying them as you describe should work.
You can specify them in your ~/.bashrc
export S3_KEY=mykey export S3_SECRET=mysecret
Or, if you are just testing locally, you can add them to the rails command.
$ S3_KEY=mykey S3_SECRET=mysecret rails server
If you do not want / cannot use environment variables, another method is to use an initializer to load credentials from the yml file : config/initializers/s3_credentials.rb
# Load AWS::S3 configuration values
config/s3_credentials.yml
development: &defaults connection: :access_key_id: AAAAAA_your-key-here :secret_access_key: 4rpsi235js_your-secret-here :use_ssl: true bucket: project-development acl: public-read production: <<: *defaults bucket: project
source share