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



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/reform/rails/railtie.rb', line 18

def active_model!
  require "reform"
  require "reform/form/active_model/model_validations"
  require "reform/form/active_model/form_builder_methods"
  require "reform/form/active_model"
  require "reform/form/active_model/validations"
  require "reform/form/multi_parameter_attributes"

  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!Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/reform/rails/railtie.rb', line 38

def dry!
  require "reform"
  require "reform/form/dry"

  require "reform/form/multi_parameter_attributes"
  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.

  Reform::Form.class_eval do
    include Reform::Form::ActiveModel # DISCUSS: only when using simple_form.
    include Reform::Form::ActiveModel::FormBuilderMethods

    include Reform::Form::Dry
  end
end