#cache required in application controller
Hi,
I am using an html form to require users to upload images. My application is now sending me the error: Need to implement #cache! if you want to use Cloudinary::CarrierWave::Storage as a cache storage.
I have the following form in my html.erb file:
<form action="/insert_outfit" method="post" class="form-horizontal" enctype="multipart/form-data">
<div class="form-group">
<label for="outfit1_box"> Outfit 1 </label>
<input type="file" id="outfit1_box" name="outfit1_from_query" class="form-control"></div>
<div class="form-group">
<label for="outfit2_box"> Outfit 2 </label>
<input type="file" id="outfit2_box" name="outfit2_from_query" class="form-control" height=100>
</div>
<button type="submit" class="btn">
Create post
</button>
</form>
In my controller file I have the following code:
def create
@outfit1 = Outfit.new
@outfit1.image = params.fetch("outfit1_from_query")
@outfit1.owner_id = session[:user_id]
@outfit2 = Outfit.new
@outfit2.image = params.fetch("outfit2_from_query")
@outfit2.owner_id = session[:user_id]
...
end
The error is highlighting the @outfit1.image code line in the application controller, since :image is the file key.
The only support resources I have found require a block loop for creating a cache, which does not make sense for my file upload form.
Any help would be appreciated!
0
-
Hi Chloe,
Could you try adding `config.cache_storage = :file` to the Carrierwave initializer, e.g.
CarrierWave.configure do |config| config.cache_storage = :file endPlease let me know how it goes.
0 -
Hey Aleksander--thanks so much!
I figured it out--needed to change "short_name" to an attribute in my model
def public_idreturn model.short_nameendchanged to:def public_idreturn model.idendAlso the public_id method is not necessary, so I could have removed it.Thanks for your help!0
Post is closed for comments.
Comments
2 comments