Module: Controllers::Sortable
- Extended by:
- ActiveSupport::Concern
- Included in:
- ContactPointsController, Crm::ActivityAgendasController, Crm::AssortmentInstructionsController, Crm::SurveysController, CustomerFiltersController, TopicCategoriesController, TopicExamsController, TopicsController
- Defined in:
- app/concerns/controllers/sortable.rb
Overview
ActiveSupport::Concern mixin: sortable.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#perform_sort(record_class) ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/concerns/controllers/sortable.rb', line 16 def perform_sort(record_class) param_name = record_class.name.tableize.singularize params[param_name].each_with_index do |id, index| record_class.where(id: id).update_all(position: index + 1) end head :ok end |
#sort ⇒ Object
12 13 14 |
# File 'app/concerns/controllers/sortable.rb', line 12 def sort perform_sort controller_name.classify.constantize end |