I'm using paperclip which has a /config/s3.yml file with the following:
common: &common
    access_key_id: XXXXXXXXXX
    secret_access_key: XXXXXXXXXXXXXXXXXXXX
developme开发者_开发问答nt:
    <<: *common
    bucket: myapp-local-dev
test:
    <<: *common
    bucket: myapp-123-test
production:
    <<: *common
    bucket: myappname-313-production
In my view I would like to dynamically be able to do something like this:
    <img src="http://s3.amazonaws.com/myapp-local-dev/1/photos/15/1/thumb/Logo%20Design%20by%20kuda-1.jpeg" />
or
    <img src="http://s3.amazonaws.com/myappname-313-production/1/photos/15/1/thumb/Logo%20Design%20by%20kuda-1.jpeg" />
Somehow, knowing the current environment and then getting the bucket name. Possible? thanks
YAML.load_file("#{Rails.root}/config/s3.yml")[Rails.env]["bucket"]
Should do the trick if you just want to return the bucket name.
If you're using Paperclip with aws/s3 this should be handled automatically though.
So:
<%= image_tag @my_obj.image.url %>
should return the desired url regardless of the environment
Hope that helps?
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论