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

  • Home
  • SEARCH
  • 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 8838605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:02:38+00:00 2026-06-14T10:02:38+00:00

I want to configure an upload path for Carrier wave Direct,which I am using

  • 0

I want to configure an upload path for Carrier wave Direct,which I am using to upload files directly to Amazon s3.In app/uploaders/myuploader.rb ,I have,

def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end

I want to modify this so that,the path looks like,
“uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{User.name}”.
so it will be some thing like,
“uploads/Users/avatar/michael_jordan/..”
Where User is the model in which the uploader is mounted.

I have gone through the source code of Carrier wave Gem in github(https://github.com/dwilkie/carrierwave_direct) and I couldn’t figure out how to pass a value from the active model object to the uploader to create the upload path(key for amazon s3). Is there a way to do this?

Thanks!
Dragon

  • 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-06-14T10:02:39+00:00Added an answer on June 14, 2026 at 10:02 am

    Ok.after one month I was forced to work on the same problem and this time I nailed it.Posting my solution here so that it may help others having the same problem,
    1)Override store_dir such that it returns an empty string,

    def store_dir
     ""
    end
    

    2)got to your controller and assign your preferred key to the “key” attribute of your uploader object like,

      @uploader = @player.avatar 
      @uploader.key =@player.name +"/\${filename}"
      #say if player name in is jordan and the filename is jordan.jpg.
      #the uplaod path  now will be   
      #http://bucketname/jordan/jordan.jpg.
    

    here player is the model object,avatar is the property on which the uploader is mounted and the key will be set as playername/filename.

    Which was what I was looking for 🙂

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

Sidebar

Related Questions

I'm new xunit and want to configure the test flow using xunit. For example,
I have an xml file that I want to configure using a bash script.
I want to configure check in policies for my Team project using visual studio
I'm trying to configure Netbeans for automatically upload PHP files to an SFTP server
i want to configure tomcat 7 to use port 80 on windows 7, but
I want to configure my log4j logging to not log messages that are 1)
I want to configure the tree view component so that would be the topmost
For the first time i use eclipse with m2e and i want to configure
I have developed a spring application, I want to configure it with apache log4j,
I've hired a new VPS and have root access. Now i want to configure

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.