Note that there are some explanatory texts on larger screens.

plurals
  1. PORails Image Upload to S3 with carrierwave and fog
    primarykey
    data
    text
    <p>Hello I've been developing a web application I and want to give users the possibility to upload profile pictures. I spent a lot of time trying to get carrierwave and fog working with s3 but have not managed to accomplish it. Any help you can give me is much apreciated.</p> <p>Update: Ive kept trying to fiddle around with it and from what i can tell the file is never uplaoding, the :image value is always empty in the Users controller.</p> <p>My uploader class.</p> <pre><code>class PhotoUploader &lt; CarrierWave::Uploader::Base storage :fog def store_dir "uploads/#images/#{model.class.to_s.underscore}" end end </code></pre> <p>The fog initializer</p> <pre><code>CarrierWave.configure do |config| config.fog_credentials = { :provider =&gt; 'AWS', :aws_access_key_id =&gt; 'xxx', :aws_secret_access_key =&gt; 'yyy', } config.fog_directory = 'pictures_dev' config.fog_public = true config.fog_attributes = {'Cache-Control'=&gt;'max-age=315576000'} end </code></pre> <p>User model</p> <pre><code>class User include Mongoid::Document .... has_one :photo .... end </code></pre> <p>Photo Model</p> <pre><code>class Photo include Mongoid::Document attr_accessible :name, :image field :image, :type =&gt; String field :name, :type =&gt; String belongs_to :user mount_uploader :image, PhotoUploader end </code></pre> <p>Photo Controller</p> <pre><code> class PhotoController &lt; ApplicationController def update @photo = Photo.find(params[:id]) if @photo.update_attributes(params[:image]) flash[:success] = "Your have updated your settings successfully." else flash[:error] = "Sorry! We are unable to update your settings. Please check your fields and try again." end redirect_to(:back) end </code></pre> <p>Upload form</p> <pre><code>= form_for @photo, :html =&gt; {:multipart =&gt; true} do |f| %p %label Photo = image_tag(@user.image_url) if @photo.image? = f.file_field :image = f.submit </code></pre> <p>This is all I can think of that is relevant, if anyone need me to post more code I'll be happy to. I am honestly stumped and any help is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload