-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Active Storage example #75
Comments
This is a hint. The controller will look like: # frozen_string_literal: true
class AssetController < ApplicationController
protect_from_forgery except: :create
def create
@upload = Asset.new(params)
authorize @upload
respond_to do |format|
format.json do
if @upload.save
render json: { id: @upload.id, url: @upload.url }
else
render json: { errors: @upload.errors.messages }
end
end
end
end
end The javascript will be like: ({
sendFile: function(upload_path, file, toSummernote) {
var data;
data = new FormData;
data.append('upload[asset]', file);
$.ajax({
data: data,
type: 'POST',
url: upload_path,
cache: false,
contentType: false,
processData: false,
success: function(data) {
console.log('file uploading...');
if (typeof data.errors !== 'undefined' && data.errors !== null) {
console.log('ops! errors...');
return $.each(data.errors, function(key, messages) {
return $.each(messages, function(key, message) {
return alert(message);
});
});
} else {
console.log('inserting image in to editor...');
return toSummernote.summernote('insertImage', data.url);
}
}
});
}
}); |
Is it possible to have an image picker to select images already uploaded to the app's asset model? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Is there an example of using
summernote-rails
with Active Storage? In the example app, it looks like you set up Active Storage (did migration, included activestorage in application.js), but ended up using carrier wave.The text was updated successfully, but these errors were encountered: