Skip to content

Instantly share code, notes, and snippets.

@sher
Forked from joshrendek/gist:1390533
Created November 24, 2011 03:00
Show Gist options
  • Save sher/1390534 to your computer and use it in GitHub Desktop.
Save sher/1390534 to your computer and use it in GitHub Desktop.
module DatatablesRails
class Structify
attr_accessor :struct
def initialize(data)
@struct = {}
@struct = data.collect{|d| d.attributes }
end
def formatter(&block)
#block.call(@struct)
@struct.each do |s|
block.call(s)
end
end
end
end
def index
respond_to do |format|
format.html
format.json {
tmp = {}
tmp = DatatablesRails::Structify.new(users_and_roles)
tmp.formatter {|u|
logger.info u['id']
u['edit'] = "<a href='#{edit_admin_user_path(u['id'])}' class='button_button'>Edit</a>"
}
render :json => tmp.struct }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment