Sha256: 9179d19ff36ec07ee1475f43ecb96a862c8a8a4b5f4b15e6274d4e7547ea0de0

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

require 'super_form/concerns/atomic_save'
require 'disposable'
require 'reform'
require 'reform/form'
require 'reform/form/active_record'
require 'reform/form/active_model'
require 'reform/form/active_model/form_builder_methods'
require "reform/form/active_model/validations"
require "reform/form/coercion"
require 'disposable/twin/parent'

Reform::Form.class_eval do
  extend ActiveModel::Naming
  extend ActiveModel::Translation
end

class SuperForm::Reform < Reform::Form
  include SuperForm::AtomicSave
  include ::Reform::Form::ActiveRecord
  include ::Reform::Form::ActiveModel
  include ::Reform::Form::ActiveModel::FormBuilderMethods
  feature Coercion

  # 定義 i18n scope
  def self.i18n_prefix(i18n_scope)
    define_singleton_method :i18n_scope do
      i18n_scope.to_sym
    end
  end

  self.i18n_prefix :activerecord

  def self.form_name(name)
    # 定義 form name (給 form 用的)
    define_singleton_method :model_name do
      active_model_name_for(name.to_s.camelize)
    end
    model(name)
  end

  private

  def self.active_model_name_for(string)
    ::ActiveModel::Name.new(self, nil, string)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
super_tools-0.0.6 lib/super_form/reform.rb
super_tools-0.0.5 lib/super_form/reform.rb
super_tools-0.0.4 lib/super_form/reform.rb
super_tools-0.0.3 lib/super_form/reform.rb
super_tools-0.0.2 lib/super_form/reform.rb
super_tools-0.0.1 lib/super_form/reform.rb