Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6073281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:15:14+00:00 2026-05-23T10:15:14+00:00

I have data stored in the following file: guess what data it is? :)

  • 0

I have data stored in the following file: guess what data it is? 🙂

S3_CREDENTIALS = Rails.root.join("config/s3.yml")

To confirm it’s working, I fired up rails console and found S3_CREDENTIALS is a Pathname object. But I’m having trouble confirming that the data is there. How would I access the bucket data, for example?

Loading development environment (Rails 3.1.0.beta1)
>> S3_CREDENTIALS.isdir
NoMethodError: undefined method `isdir' for #<Pathname:0x10212f6f8>
    from (irb):1
>> S3_CREDENTIALS.size
=> 282
>> S3_CREDENTIALS.data
NoMethodError: undefined method `data' for #<Pathname:0x10212f6f8>
    from (irb):3
>> S3_CREDENTIALS[:bucket]
NoMethodError: undefined method `[]' for #<Pathname:0x10212f6f8>
    from (irb):4
>> 

On a related note, would this still work if I changed the file from s3.yml to s3.json?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:15:15+00:00Added an answer on May 23, 2026 at 10:15 am

    If you are using this as s3 storage with Paperclip you want to leave it as yml. Inside your initializers (config/initializers) create a file called:

    app_config.rb

    AppConfig = YAML.load(File.read(Rails.root + 'config' + 'config.yml'))[Rails.env].with_indifferent_access
    

    Your config for all your s3 stuff should be in the format:

    config.yml

    development:
      s3:
        access_id: access-id
        secret_key: secret
        bucket_name: your-bucket-name-for-development
    staging:
      s3:
        access_id: access-id
        secret_key: secret
        bucket_name: your-bucket-name-for-staging
    production:
      s3:
        access_id: access-id
        secret_key: secret
        bucket_name: your-bucket-name-for-production
    

    At this point you should be able to go into your console and access your s3 data by just putting in:

    AppConfig[:s3]
    

    And you should get a hash back with all your data like:

    {"access_id"=>"access-id", "bucket_name"=>"your-bucket-name-for-development", "secret_key"=>"secret"}
    

    I just have the above as an example if you want to test your s3 stuff on development, but ordinarily you would just save to your local file directory on development, and use s3 for remote staging and production environments.

    Accessing the bucket data is a different conversation and depends how you have your bucket data associated to your model. If for example your bucket data was associated to a Photo model like so:

    photo.rb

    require 'paperclip'
    
    class Photo < ActiveRecord::Base
      belongs_to :album
      before_save :set_orientation
    
      if AppConfig['s3']
        has_attached_file :data, 
          :styles => { 
            :thumb => "200x200>",
            :medium => "700x700>" 
          },
          :storage => :s3, 
          :default_style => :medium,
          :bucket => AppConfig['s3']['bucket_name'],
          :s3_credentials => { :access_key_id => AppConfig['s3']['access_id'], :secret_access_key => AppConfig['s3']['secret_key'] },
          :s3_headers => { 'Cache-Control' => 'max-age=315576000', 'Expires' => 10.years.from_now.httpdate },
          :path => "/:class/:id/:style/:filename"
      else
        has_attached_file :data,
          :styles => { 
            :thumb => "200x200>",
            :medium => "700x700>"
          },
          :storage => :filesystem, 
          :default_style => :medium
      end
    
      private
      def set_orientation
        self.orientation = Paperclip::Geometry.from_file(self.data.to_file).horizontal? ? 'horizontal' : 'vertical'
      end
    end
    

    I have my attach file name called data, as illustrated in has_attached_file :data. So to access some bucket data, I would call:

    Photo.first.data(:thumb)
    

    And that would pull the s3 url that the thumbnail photo was storing for the first Photo object that was returned. The above example is also using the ‘paperclip’ gem and ‘aws-s3’ gem.

    config.gem 'aws-s3', :version => '>=0.6.2', :lib => 'aws/s3'
    config.gem 'paperclip'
    

    Hope this help you on your way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario: I have various user's data stored in my database.
I have GPS data stored as as .tcx file. This is a xml file
I have an XML file with data stored like this: <myxml> <item name=column18>88744544</item> <item
Visual Studio 2010, Silverlight 4, and C#. I have the following data stored in
I have the following data in a Tab delimited file: _ DATA _ Col1
I have the following simple jQuery: $.get('Data.csv', function(data) { alert(data); }); Data.csv is stored
I have huge data matrices stored in a MATLAB M-file and I will explain
I have data stored as below in an MS Access database: Date User 20090101
Greetings, I have data stored on mysql with delimiter , in 1 table. I
I have some data stored as ArrayList . And when I want to backup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.