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


56
57
58
# File 'lib/reform/form/active_model.rb', line 56

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

#model_nameObject



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

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