Skip to content

Instantly share code, notes, and snippets.

@amolpujari
Created October 23, 2013 04:49
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 amolpujari/7112764 to your computer and use it in GitHub Desktop.
Save amolpujari/7112764 to your computer and use it in GitHub Desktop.
activeadmin tweaks
module ActiveAdmin
module Views
class IndexAsTable < ActiveAdmin::Component
def editable_text_column resource, attr
val = resource.send(attr)
val = "&nbsp;" if val.blank?
html = %{
<div id='editable_text_column_#{resource.id}'
class='editable_text_column'
ondblclick='admin.editable_text_column_do(this)' >
#{val}
</div>
<input
data-path='#{resource.class.name.tableize}'
data-attr='#{attr}'
data-resource-id='#{resource.id}'
class='editable_text_column admin-editable'
id='editable_text_column_#{resource.id}'
style='display:none;' />
}
html.html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment