SammyLin / redactor-rails

This repo is deprecated. Please check out official gem for Redactor 2. https://github.com/Redactor2/redactor2_rails
MIT License
389 stars 253 forks source link

Silent Upload Failure #136

Closed activestylus closed 9 years ago

activestylus commented 9 years ago

I can't seem to get redactor to upload images. The post action goes off without a hitch, but no actual image files are ever uploaded into the folder I've established for storage. Here is my uploader

# encoding: utf-8
class RedactorRailsPictureUploader < CarrierWave::Uploader::Base
  include RedactorRails::Backend::CarrierWave
  include CarrierWave::MiniMagick

  storage :file

  def store_dir
    "system/uploads/redactor/images"
  end

  process :read_dimensions

  def extension_white_list
    RedactorRails.image_file_types
  end
end

A peek at the logs while I attempt to add an image to my redactor text field:

Started POST "/redactor_rails/pictures?authenticity_token=RHT%2VsQtzTvm698I4tu3hVRk5nOmLJHfK5O4efYm6AG4%3D" for 127.0.0.1 at 2015-04-06 21:39:47 +0200
Processing by RedactorRails::PicturesController#create as HTML
  Parameters: {
    "file"=>
      #<ActionDispatch::Http::UploadedFile:0x007fe4fe33a3c0   
        @original_filename="photo-me.jpg",
        @content_type="image/jpeg",
        @headers="Content-Disposition: form-data;
          name=\"file\";
          filename=\"photo-me.jpg\"
          Content-Type: image/jpeg",
          @tempfile=#<File:/var/folders/41/s0jw7yr93jggtg__1h9d0yz00000gn/T/RackMultipart20150406-29185-6eg4b>>, "authenticity_token"=>"RHT%2VsQtzTvm698I4tu3hVRk5nOmLJHfK5O4efYm6AG4%3D"}
   (0.2ms)  BEGIN
  SQL (1.0ms)  INSERT INTO "redactor_assets" ("assetable_id", "assetable_type", "created_at", "data_content_type", "data_file_name", "data_file_size", "height", "type", "updated_at", "user_id", "width") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING "id"  [["assetable_id", 1], ["assetable_type", "User"], ["created_at", Mon, 06 Apr 2015 19:39:47 UTC +00:00], ["data_content_type", "image/jpeg"], ["data_file_name", "photo-me.jpg"], ["data_file_size", 36640], ["height", 421], ["type", "RedactorRails::Picture"], ["updated_at", Mon, 06 Apr 2015 19:39:47 UTC +00:00], ["user_id", 1], ["width", 640]]
   (0.7ms)  COMMIT
  Rendered text template (0.0ms)
Completed 200 OK in 323ms (Views: 1.4ms | ActiveRecord: 3.5ms)

Started GET "/system/uploads/redactor/images/photo-me.jpg" for 127.0.0.1 at 2015-04-06 21:39:47 +0200

ActionController::RoutingError (No route matches [GET] "/system/uploads/redactor/images/photo-me.jpg"):

Inspected that images folder and I see no files are in there.

Sanity Check:

Any ideas?

activestylus commented 9 years ago

Turned out to be a Carrierwave configuration issue.

in config/initializers/carrierwave.rb

require 'carrierwave/orm/activerecord'

CarrierWave.configure do |config|
  config.storage = :file
  config.root = Rails.root
end

I substituted one line to get this working with redactor uploader:

config.root = "#{Rails.root}/public"

Hopefully this helps someone else

mbryk commented 8 years ago

THANK YOU