Created
November 24, 2011 02:59
-
-
Save joshrendek/1390533 to your computer and use it in GitHub Desktop.
This file contains 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
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