ruby on rails - Carrierwave uploads don't appear on POST -
i'm following railscast tutorial carrierwave uploads, , have same files set up. upload works fine if upload file via console, form doesn't seem post correctly.
i've got basic form, includes:
<%= f.label :receipt %><br> <%= f.file_field :receipt %>
rails 4 automatically include enctype="multipart/form-data"
tag on form.
when submit form, take @ server logs. upload shows in parameters:
"receipt"=>#<actiondispatch::http::uploadedfile:0x007fcb25c624e0 @tempfile=#<tempfile:/var/folders/ty/yks2xd9n76z9p49qzprvt1900000gn/t/rackmultipart20130903-53712-17zblz4>, @original_filename="avatar.jpg", @content_type="image/jpeg", @headers="content-disposition: form-data; name=\"expense[receipt]\"; filename=\"avatar.jpg\"\r\ncontent-type: image/jpeg\r\n">},
however, insert statement doesn't include mention of receipt field or file. there isn't error. file not uploaded directory specified in carrierwave either.
any ideas on might going wrong here? not duplicate of this answer issue jquery mobile. i'm stumped on what's going on.
edit: should include model well:
class expense < activerecord::base mount_uploader :receipt, receiptuploader end
i have stock uploader class well, generated carrierwave:
class receiptuploader < carrierwave::uploader::base storage :file def store_dir "receipts" end end
edit 2: here controller creating expense:
def new @expense = expense.new end def create @expense = expense.new(expense_params) respond_to |format| if @expense.save format.html { redirect_to @expense, notice: 'expense created.' } format.json { render action: 'show', status: :created, location: @expense } else format.html { render action: 'new' } format.json { render json: @expense.errors, status: :unprocessable_entity } end end end
looks params wasn't permitting upload go through. rookie mistake.
Comments
Post a Comment