ruby on rails - replacing certain column values with "-" in a will_paginate result set without affecting sorting -


i have model table 3 fields: "id", "amount" , "type". im calling paginate method display data need replace amount "-" if type = "specific_type".

i can replacing values in view "-" if type condition met. screws sort order "-" values evaluated 0 replacing values in view still leaves me incorrect sort order.

i thought using find_by_sql , trying create virtual field using case statement

select *, case type when 'specific' amount else '-' end amounts;

this way, can use virtual column.

the problem need take in param hash of options have manually render sql clause. sounds tedious unless there's better way of doing it.

in controller:

def index     @resources = []     your_resources = resource.find(:all)             your_resources.each |resource|         resource.amount = '-' if resource.amount = "specific_type"         @resources << resource       end  end  

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -