app/controllers/concerns/entities_sorter.rb
# The default values are 'created_at' and true for descending, resulting in most recently created first.
# This is overridden either by setting :sort and :desc on the Template instance or by providing
# sort= and desc= query parameters. These query parameters take precedence.
The default values are 'created_at' and true for descending, resulting in most recently created first.
This is overridden either by setting :sort and :desc on the Template instance or by providing
sort= and desc= query parameters. These query parameters take precedence.
The default values are ' created_at ' and true for descending resulting in most recently created first . This is overridden either by setting : sort and : desc on the Template instance or by providing sort = and desc = query parameters . These query parameters take precedence .
def entities_order(default = @template.default_api_order)
    if params[:sort] && ['created_at', 'updated_at', 'published_at'].include?(params[:sort])
      {params[:sort] => (params[:desc] == 'false' ? :asc : :desc)}
    elsif params[:sort] && @template.dynamic_attributes.include?(params[:sort])
      "(data -> '#{params[:sort]}') #{params[:desc] == 'true' ? 'DESC' : 'ASC'}"
    else
      default
    end
  end
def entities_order ( default = @template . default_api_order ) if params [ :sort ] && [ 'created_at' , 'updated_at' , 'published_at' ] . include? ( params [ :sort ] ) { params [ :sort ] => ( params [ :desc ] == 'false' ? :asc : :desc ) } elsif params [ :sort ] && @template . dynamic_attributes . include? ( params [ :sort ] ) "(data -> '#{params[:sort]}') #{params[:desc] == 'true' ? 'DESC' : 'ASC'}" else default end end
The default values are 'created_at' and true for descending, resulting in most recently created first.
The default values are ' created_at ' and true for descending resulting in most recently created first .
# If params[:desc] is 'true', nil or anything other than 'false', returns :desc by default # If params[:desc] is 'false', nil or anything other than 'true', returns :asc by default # Know that `-->` exists and casts JSON to text if needed.
default
default_api_order