Image resizing doesn't work in design with carrier-aws

Image files should be modified as they are loaded.

The code ' process resize_to_fill: [800, 350]'

in the loader file works in production but not in my development environment. (I'm using a vagrant)

My file config/initializers/carrierwave.rb

was modified with the following code:

CarrierWave.configure do |config|
  if Rails.env.development?
    config.cache_dir = '/home/vagrant/uploads_tmp/tmp/uploads'
    config.root = '/home/vagrant/uploads_tmp/tmp'
  end
end

      

Because without this code, I get the following error (due to using Windows):

Errno::ETXTBSY in Instructor::CoursesController#create

      

and cannot be loaded at all during development.

My controller action looks like this:

def create
  @course = current_user.courses.create(course_params)
  if @course.valid?
    redirect_to instructor_course_path(@course)
  else     
    render :new, status: :unprocessable_entity
  end
end

      

With an error thrown in the assignment line of the instance variables.

Since you added the initializer code, some image files are kept at their original size, while others are saved mostly in empty space (with a small stripe from the image at the top). I don't seem to see anything special about the looks in any class! Interestingly, this doesn't happen when the app is deployed to heroku.

Can anyone explain:

1) What is causing the original error, and why is the initializer code fixing it.

2) What happens to the image upload?

EDIT

After posting my question, I found that the files are loaded without fixing the code in the initializer; in this case, the problem is with access to the file. I omitted the second line of the error message in my original question, which should actually be the clue to the problem: Text file busy @ unlink_internal - /vagrant/src/flixter/public/uploads/tmp/1499336954-11657-000‌​1-9160/ecriture.jpg

Here is the complete stack trace (original error without fixing the initializer code):

Errno::ETXTBSY (Text file busy @ unlink_internal - /vagrant/src/flixter/public/uploads/tmp/1499420789-13682-000‌​1-6708/ben-white-148‌​430.jpg): app/controllers/instructor/courses_controller.rb:10:in 'create' Rendering /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems‌​/actionpack-5.0.3/li‌​b/ action_dispatch/middleware/templates/rescues/diagnostics.htm‌​l.erb within rescues/layout Rendering /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems‌​/actionpack-5.0.3/li‌​b/ action_dispatch/middleware/templates/rescues/_source.html.er‌​b Rendered /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems‌​/actionpack-5.0.3/li‌​b/action_dispatch/middleware/templates/rescues/_source.html.erb (5.3ms) Rendering /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems‌​/actionpack-5.0.3/li‌​b/ action_dispatch/middleware/templates/rescues/_trace.html.erb Rendered /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems‌​/actionpack-5.0.3/li‌​b/a ction_dispatch/middleware/templates/rescues/_trace.html.erb (2.3ms) Rendering /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems‌​/actionpack-5.0.3/li‌​b/ action_dispatch/middleware/templates/rescues/_request_and_re‌​sponse.html.erb Rendered /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems‌​/actionpack-5.0.3/li‌​b/a ction_dispatch/middleware/templates/rescues/_request_and_res‌​ponse.html.erb (2.0ms) Rendered /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems‌​/actionpack-5.0.3/li‌​b/a ction_dispatch/middleware/templates/rescues/diagnostics.html‌​.erb within rescues/layout (26.1ms)

I still don't know why the initializer code partially fixes the error!

+3


source to share





All Articles