Module: Reform::Form::ActiveModel::ClassMethods

Defined in:
lib/reform/form/active_model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

this module is only meant to extend (not include). # DISCUSS: is this a sustainable concept?



61
62
63
64
65
66
# File 'lib/reform/form/active_model.rb', line 61

def self.extended(base)
  base.class_eval do
    extend Uber::InheritableAttribute
    inheritable_attr :model_options
  end
end

Instance Method Details

#model(main_model, options = {}) ⇒ Object

Set a model name for this form if the infered is wrong.

class CoverSongForm < Reform::Form
  model :song


73
74
75
# File 'lib/reform/form/active_model.rb', line 73

def model(main_model, options={})
  self.model_options = [main_model, options]
end

#model_nameObject



77
78
79
80
81
82
83
84
85
# File 'lib/reform/form/active_model.rb', line 77

def model_name
  if model_options
    form_name = model_options.first.to_s.camelize
  else
    form_name = name.sub(/Form$/, "")
  end

  active_model_name_for(form_name)
end