spree-contrib/spree_drop_ship

View on GitHub
app/controllers/ckeditor/pictures_controller_decorator.rb

Summary

Maintainability
A
30 mins
Test Coverage
if defined?(Ckeditor::PicturesController)
  Ckeditor::PicturesController.class_eval do
    load_and_authorize_resource class: 'Ckeditor::Picture'
    after_action :set_supplier, only: [:create]

    def index; end

    private

    def set_supplier
      if spree_current_user.supplier? && @picture
        @picture.supplier = spree_current_user.supplier
        @picture.save
      end
    end
  end
end