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

Included in:
Composition::ClassMethods
Defined in:
lib/reform/form/active_model.rb

Instance Method Summary collapse

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


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

def model(main_model, options={})
  @model_options = [main_model, options]  # FIXME: make inheritable!
end

#model_nameObject



67
68
69
70
71
72
73
74
75
# File 'lib/reform/form/active_model.rb', line 67

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