Module: Reform::Form::ActiveRecord
- Defined in:
- lib/reform/form/active_record.rb
Defined Under Namespace
Modules: ClassMethods Classes: UniquenessValidator
Class Method Summary collapse
Instance Method Summary collapse
-
#column_for_attribute(name) ⇒ Object
Delegate column for attribute to the model to support simple_form’s attribute type interrogation.
- #model_for_property(name) ⇒ Object
Class Method Details
.included(base) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/reform/form/active_record.rb', line 2 def self.included(base) base.class_eval do register_feature Reform::Form::ActiveRecord include Reform::Form::ActiveModel extend ClassMethods end end |
Instance Method Details
#column_for_attribute(name) ⇒ Object
Delegate column for attribute to the model to support simple_form’s attribute type interrogation.
48 49 50 |
# File 'lib/reform/form/active_record.rb', line 48 def column_for_attribute(name) model_for_property(name).column_for_attribute(name) end |
#model_for_property(name) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/reform/form/active_record.rb', line 39 def model_for_property(name) return model unless is_a?(Reform::Form::Composition) # i am too lazy for proper inheritance. there should be a ActiveRecord::Composition that handles this. model_name = mapper.representable_attrs.get(name)[:on] model[model_name] end |