tab/app/controllers/concerns/data_table.rb
2015-09-09 14:46:06 +02:00

23 lines
526 B
Ruby

module DataTable
extend ActiveSupport::Concern
def apply_filter(user, params)
p selection_to_json(user, user.transactions)
selection_to_json(user, user.transactions)
end
private
def selection_to_json(user, selection)
{ data: selection.map { |transaction| {
amount: transaction.signed_amount_for(user),
origin: transaction.origin,
message: transaction.message,
peer: transaction.peer_of(user).try(:name),
time: transaction.created_at
} }
}
end
end