Sha256: 3b2c7e9bfd71ff8b18c61a668d9ddf772defb9c9d6ef0fa8144876b0ebd30251
Contents?: true
Size: 1021 Bytes
Versions: 20
Compression:
Stored size: 1021 Bytes
Contents
# Parameter Model module KepplerFrontend class Parameter < ActiveRecord::Base include ActivityHistory include CloneRecord require 'csv' acts_as_list belongs_to :function # Fields for the search form in the navbar include KepplerFrontend::Concerns::StringActions validates_presence_of :name before_validation :without_special_characters def self.search_field fields = ["name", "position", "deleted_at"] build_query(fields, :or, :cont) end def self.upload(file) CSV.foreach(file.path, headers: true) do |row| begin self.create! row.to_hash rescue => err end end end def self.sorter(params) params.each_with_index do |id, idx| self.find(id).update(position: idx.to_i+1) end end # Funcion para armar el query de ransack def self.build_query(fields, operator, conf) query = fields.join("_#{operator}_") query << "_#{conf}" query.to_sym end end end
Version data entries
20 entries across 20 versions & 1 rubygems