Note that there are some explanatory texts on larger screens.

plurals
  1. POCarrierwave not uploading - no error shown
    primarykey
    data
    text
    <p>I've been working on this all night and it makes no sense. I'm adapting an old photo web app to have albums in it. I made "fails" (basically images) a nested resource of albums. I am using carrierwave to upload files to an S3 bucket. </p> <p><em>the weird thing is: the upload works perfectly fine for the album model (album image), but it doesn't upload for the fail model.</em> </p> <p>I don't see why it'd be a problem that it's a nested resource now. It's not a problem displaying it's that for some reason, it goes through the form fine, passes validations fine, no errors are thrown, it redirects to fails#index like it was successful, but there is nothing in the db or in S3.</p> <p>Code is below. All code at <a href="https://github.com/spq24/failboard" rel="nofollow">https://github.com/spq24/failboard</a></p> <p>Fail Model</p> <pre><code>class Fail &lt; ActiveRecord::Base attr_accessible :description, :image, :remote_image_url, :fail_title, :tag_list, :processed, :youtube_url, :album_id make_voteable acts_as_taggable belongs_to :album mount_uploader :image, ImageUploader validates :description, length: { :maximum =&gt; 200 } validates :album_id, presence: true validates :image, presence: true validates :fail_title, presence: true, length: { :maximum =&gt; 50 } validate :maximum_amount_of_tags def maximum_amount_of_tags number_of_tags = tag_list_cache_on("tags").uniq.length errors.add(:base, "Please only add up to 5 tags") if number_of_tags &gt; 5 end before_save :update_attachment_attributes def update_attachment_attributes if image.present? &amp;&amp; image_changed? self.content_type = image.file.content_type self.file_size = image.file.size end end def next user.fails.where("id &gt; ?", id).order("id ASC").first end def prev user.fails.where("id &lt; ?", id).order("id DESC").first end end </code></pre> <p>Album Model</p> <pre><code>class Album &lt; ActiveRecord::Base attr_accessible :name, :image, :image_url, :created_at belongs_to :user has_many :fails, dependent: :destroy mount_uploader :image, ImageUploader validates :user_id, presence: true validates :image, presence: true validates :name, presence: true, length: { :maximum =&gt; 50 } before_save :update_attachment_attributes def update_attachment_attributes if image.present? &amp;&amp; image_changed? #self.content_type = image.file.content_type #self.file_size = image.file.size end end def next user.fails.where("id &gt; ?", id).order("id ASC").first end def prev user.fails.where("id &lt; ?", id).order("id DESC").first end end </code></pre> <p>Fails Controller</p> <pre><code> def new @fail = Fail.new(:album_id =&gt; params[:album_id]) respond_to do |format| format.html # new.html.erb format.json { render json: @fail } end end def create @fail = Fail.new(params[:fail]) respond_to do |format| if @fail.save format.html { redirect_to @fail.album, notice: 'You added a new photo!' } format.json { render json: @fail, status: :created, location: @fail } else format.html { render action: "new" } format.json { render json: @fail.errors, status: :unprocessable_entity } end end end </code></pre> <p>routes.rb</p> <pre><code>resources :albums do get 'tags/:tag', to: 'fails#index', as: :tag resources :fails do member do post :up_vote end end </code></pre> <p>Debug Hash (this turns red when I try to upload, but I don't see anything that would cause the error)</p> <p>Here is the debug info:</p> <pre><code>{"utf8"=&gt;"✓", "authenticity_token"=&gt;"Hz6Gl95ultYDNIEjQioIckB8JXQwhiMxXIM9jrfqd5Q=", "fail"=&gt;{"fail_title"=&gt;"tester", "image"=&gt;#&lt;ActionDispatch::Http::UploadedFile:0x56195e8 @original_filename="pic19.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"fail[image]\"; filename=\"pic19.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#&lt;File:C:/Users/Kinertia/AppData/Local/Temp/RackMultipart20131125-10428-m2ktp2&gt;&gt;, "description"=&gt;"", "tag_list"=&gt;"test"}, "commit"=&gt;"Create Fail", "controller"=&gt;"fails", "action"=&gt;"index"} </code></pre> <p>If there is anything else needed please let me know and I will put it here. Thank you for all the help!</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.
    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