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 7617871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:15:17+00:00 2026-05-31T03:15:17+00:00

I am using Rails 3 and carrierwave gem. My problem is the next: I

  • 0

I am using Rails 3 and carrierwave gem.

My problem is the next:

I am coding a wizard form with multiple models and relations. So My application has products which has many images through Image model (Its has been mounted with carrierwave).

Because the form has many steps I want save temporaly the images with cache option in CarrierWave. then i last step i want recover the images and load my product. So I create a model called TempData which save temporaly data (In this case cache_name), a type_identifier and a mark can_be_deleted.

For example these are my models:

Product Model:

class Product < ActiveRecord::Base
  has_many :images, :as => :imageable, :dependent => :destroy
  def save_images_in_temporal_folder(images_attributes)
    begin
      uploader = ImageUploader.new
      images_attributes.to_hash.each do |image|
        uploader.cache!(image[1]['filename'])
        TempData.create(:data => uploader.cache_name, :can_deleted => false, :type_name => TempDataType.product_image_upload_to_words)
      end
    rescue

    end
  end

  def load_images_from_temporal_folder
    begin
      uploader = ImageUploader.new
      tmp_images = []
      TempData.find_all_by_can_deleted_and_type_name(false, TempDataType.product_image_upload_to_words).map(&:data).each do |cache_name|
        tmp_images << uploader.retrieve_from_cache!(cache_name)
      end
      tmp_images
    rescue

    end
  end
end

Image model

class Image < ActiveRecord::Base
    attr_accessible :imageable_type, :imageable_id, :filename

    belongs_to :imageable, :polymorphic => true
    mount_uploader :filename, ImageUploader

    #validates :filename, :presence => true
end

My ImageUploader:

class ImageUploader < CarrierWave::Uploader::Base
  configure do |config|
    config.remove_previously_stored_files_after_update = false
  end

  include CarrierWave::RMagick

  storage :file

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

  def self.store_dir_for_file(model, mounted, filename, version = "")
    filename = "#{version}_#{filename}" unless version.blank?
    "uploads/#{model.class.to_s.underscore}/#{mounted}/#{model.id}/#{filename}"
  end

  process :resize_to_limit => [200, 300]

  version :thumb do
    process :resize_to_limit => [50, 50]
  end

  version :big do
    process :resize_to_limit => [400, 400]
  end

  def extension_white_list
    %w(jpg jpeg gif png)
  end

end

So How i save/cache the images with model and mount information?. How retrieve the cache and load my product with images in cache?

Thanks in advance. Sorry for my english and if you need more information comment this post.

  • 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-31T03:15:18+00:00Added an answer on May 31, 2026 at 3:15 am

    View the next link:

    CarrierWave with ActiveResource

    Also I create a model which storage temporal data. Here I save the cache_name of carrierwave. When i save the product mark these register as can_be_deleted. Then I write a task which delete these registers and clean Carrierwave cache files.

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

Sidebar

Related Questions

In my rails 3 application, I am using carrierwave gem (version 0.5.6). I would
I am using the carrierwave gem with Rmagick in a Rails app. I've set
I am using the carrierwave gem to manage file uploads in my rails 3
I am having problem uploading image to mongodb using rails and carrierwave. This is
I'm using carrierwave in my application. The problem is it works well in development
I am using the carrierwave gem (http://github.com/jnicklas/carrierwave) for ruby on rails. How do I
I'm using CarrierWave / Fog in a Rails application to upload videos to Amazon
I'm using rails, but doing all my Javascript unobtrusively using jQuery in application.js .
I'm making a rails 3.1 app using carrierwave to upload files to aws s3.
Using Rails 3.2 and ruby 1.9.3p0 I am trying out the gem delayed_job. I

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.