Module: Recourse::Recoursive

Defined in:
lib/recourse/recoursive.rb

Overview

Extends every Active Record model, so each one can say how it is labelled.

Instance Method Summary collapse

Instance Method Details

#recourse_labelObject

Column a combobox shows for a record, and selects alongside its id.



7
# File 'lib/recourse/recoursive.rb', line 7

def recourse_label = :name

#recourse_typed_label?Boolean

True when the label has a length, so it is short enough to be typed and a form can ask for the value instead of listing every record to pick from.

Returns:

  • (Boolean)


11
12
13
# File 'lib/recourse/recoursive.rb', line 11

def recourse_typed_label?
  validators_on(recourse_label).any? ActiveModel::Validations::LengthValidator
end