I have a model table with 3 fields: "id", "amount" and "type". Im calling the paginate method to display the data but I need to replace the amount with "-" if type = "specific_type".
I can do this by replacing the values in the view with a "-" if the type condition is met. But this screws up the sort order as I would like the "-" values to be effectively evaluated as 0 but replacing values only in the view still leaves me with an incorrect sort order.
I thought about using find_by_sql and trying to create a virtual field using a CASE statement
select *, CASE type WHEN 'specific' THEN amount ELSE '-' END from amounts;
this way, I can use the virtual column.
The problem is that I need to take in a param hash of options which I would then have to manually render to SQL where clause. This sounds tedious unless there's a better way of doing it.