class ActiveAdmin::ResourceDSL
def order_by(column, &block)
end
['COALESCE(NULLIF(last_name, ''), first_name), first_name', order_clause.order].join(' ')
order_by(:full_name) do |order_clause|
# by last_name but in the case that there is no last name, by first_name.
end
[order_clause.to_sql, 'NULLS LAST'].join(' ') if order_clause.order == 'desc'
order_by(:age) do |order_clause|
# nulls last
For example:
Redefine sort behaviour for column
def order_by(column, &block) config.ordering[column] = block end