Class: Pairer::ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Pairer::ApplicationRecord
- Defined in:
- app/models/pairer/application_record.rb
Instance Method Summary collapse
Instance Method Details
#in_order_of(column, order_array) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/pairer/application_record.rb', line 19 def in_order_of(column, order_array) Arel.sql( <<~SQL case #{table_name}.#{column} #{order_array.map_with_index{|x, i| "when '#{x}' then #{i+1}"}.join(" ")} else #{order_array.size+1} end SQL ) end |
#to_param ⇒ Object
14 15 16 |
# File 'app/models/pairer/application_record.rb', line 14 def to_param try(:public_id) || id end |