I need to sort some resources with mysql. It requires of me to handle it like this
scope :sorted_by_source, -> { select("set_name(source) as source_name").order("source_name ASC") }
So as you can see function set_name is gonna return something which will later allow me to do order by. However i dont know how to define this function in Rails? Where should i put it, whats the syntax? (I'm gonna need switch statement)
Using Rails 3 and MySql