class Reform::Rails::Railtie

Public Instance Methods

active_model!() click to toggle source
# 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) click to toggle source
# 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