Last active
August 23, 2020 14:22
-
-
Save balvig/e77749fd3d2d4c05f34b to your computer and use it in GitHub Desktop.
Active Admin Cloudinary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app / assets / javascripts / active_admin.js | |
//= require active_admin/base | |
//= require jquery.ui.widget | |
//= require jquery.iframe-transport | |
//= require jquery.fileupload | |
//= require cloudinary/jquery.cloudinary | |
//= require attachinary | |
//= require attachments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config / initializers / active_admin_cloudinary.rb | |
# The Active Admin equivalent of putting this in your application layout: | |
# <head> | |
# <%= cloudinary_js_config %> | |
# </head> | |
module ActiveAdmin | |
module Views | |
module Pages | |
class Base < Arbre::HTML::Document | |
alias_method :original_build_head, :build_active_admin_head | |
def build_active_admin_head | |
original_build_head | |
within @head do | |
text_node cloudinary_js_config | |
end | |
end | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app / assets / javascripts / attachments.js | |
jQuery -> | |
$('.attachinary-input').attachinary() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app / inputs / formtastic_attachinary_input.rb | |
class FormtasticAttachinaryInput | |
include Formtastic::Inputs::Base | |
attr_reader :attachinary_options | |
def to_html | |
input_wrapping do | |
label_html << | |
template.builder_attachinary_file_field_tag(method, @builder, { html: input_html_options }) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Super! Tkts a lot!!!
Just an update comment. If you have this errors : “couldn't find file 'jquery.ui.widget” on rails 5., you need to install in your gemfile :
gem "jquery-fileupload-rails"
and change in # app / assets / javascripts / active_admin.js :
//= require jquery.ui.widget
//= require jquery.iframe-transport
//= require jquery.fileupload
by
//= require jquery-fileupload/vendor/jquery.ui.widget
//= require jquery-fileupload/jquery.iframe-transport
//= require jquery-fileupload/jquery.fileupload
See: https://github.com/tors/jquery-fileupload-rails