2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/baza_models/helpers/ransacker_helper.rb', line 2
def bm_sort_link(ransacker, attribute)
require "html_gen"
label = ransacker.klass.human_attribute_name(attribute)
new_params = params.clone
new_params[:q] ||= {}
sort_asc = "#{attribute} asc"
if new_params[:q][:s] == sort_asc
new_params[:q][:s] = "#{attribute} desc"
else
new_params[:q][:s] = sort_asc
end
href = url_for(new_params)
element = HtmlGen::Element.new(:a, str: label, attr: {href: href})
element.html
end
|