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

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
# File 'lib/reform/form/active_record.rb', line 3

def self.included(base)
  base.class_eval do
    include Reform::Form::ActiveModel
    extend ClassMethods
  end
end

Instance Method Details

#model_for_property(name) ⇒ Object



43
44
45
46
47
48
# File 'lib/reform/form/active_record.rb', line 43

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[name].options[:on]
  send(model_name)
end

#saveObject



37
38
39
40
41
# File 'lib/reform/form/active_record.rb', line 37

def save(*)
  super.tap do
    model.save unless block_given? # DISCUSS: should we implement nested saving here?
  end
end