Method: Binda::ComponentsHelper#get_sort_link_by
- Defined in:
- app/helpers/binda/components_helper.rb
#get_sort_link_by(argument) ⇒ string
Get sort link by argument
This method returns a URL which contains the current sort options
and update just the title one. The URL then is used to change the
sorting of the index in which is used.
Rails guide reference –> guides.rubyonrails.org/action_controller_overview.html#hash-and-array-parameters
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/helpers/binda/components_helper.rb', line 72 def get_sort_link_by argument arg = "#{argument}".to_sym if params[:order].nil? structure_components_path( [@structure], { order: {arg => "DESC"} } ) else order_hash = params[:order].permit(:name, :publish_state).to_h if order_hash[arg] == "ASC" order_hash[arg] = "DESC" structure_components_path( [@structure], { order: order_hash } ) else order_hash[arg] = "ASC" structure_components_path( [@structure], { order: order_hash } ) end end end |