Class: Renalware::Patients::MDMsController::SqlView

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/renalware/patients/mdms_controller.rb

Instance Method Summary collapse

Instance Method Details

#klassObject

Create a class under Renalware

for this SQL name

Note that Ransack search_form_for requires our otherwise anonymous class to have a name.



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/controllers/renalware/patients/mdms_controller.rb', line 70

def klass
  return Renalware.const_get(class_name) if class_exists?

  underlying_view_name = view_name
  Class.new(ApplicationRecord) do
    self.table_name = underlying_view_name
    define_method(:to_s, ->(_x) { patient_name })
    define_method(:to_param, -> { secure_id })
  end.tap do |klass|
    Renalware.const_set(class_name, klass)
    # klass.connection # not sure this is required.
  end
end