Class: Reform::Rails::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/reform/rails/railtie.rb

Instance Method Summary collapse

Instance Method Details

#active_model!Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/reform/rails/railtie.rb', line 22

def active_model!
  require "reform/form/active_model/form_builder_methods"
  require "reform/form/active_model"

  require "reform/form/active_model/model_validations"
  require "reform/form/active_model/validations"

  require "reform/active_record" if defined?(::ActiveRecord)
  require "reform/mongoid" if defined?(::Mongoid)

  Reform::Form.class_eval do
    include Reform::Form::ActiveModel
    include Reform::Form::ActiveModel::FormBuilderMethods
    include Reform::Form::ActiveRecord if defined?(::ActiveRecord)
    include Reform::Form::Mongoid if defined?(::Mongoid)
    include Reform::Form::ActiveModel::Validations
  end
end

#dry!(enable_am = true) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/reform/rails/railtie.rb', line 41

def dry!(enable_am = true)
  if enable_am
    require "reform/form/active_model/form_builder_methods" # this is for simple_form, etc.

    # This adds Form#persisted? and all the other crap #form_for depends on. Grrrr.
    require "reform/form/active_model" # DISCUSS: only when using simple_form.
  end

  require "reform/form/dry"

  Reform::Form.class_eval do
    if enable_am
      include Reform::Form::ActiveModel
      include Reform::Form::ActiveModel::FormBuilderMethods
    end

    include Reform::Form::Dry
  end
end