Skip to content

Instantly share code, notes, and snippets.

@xlanex6
Forked from balvig/active_admin.js
Created November 30, 2016 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xlanex6/46c15052acf2329ff6d1d03adf984dc3 to your computer and use it in GitHub Desktop.
Save xlanex6/46c15052acf2329ff6d1d03adf984dc3 to your computer and use it in GitHub Desktop.
Active Admin Cloudinary
# 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
# 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
# app / assets / javascripts / attachments.js
jQuery ->
$('.attachinary-input').attachinary()
# 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