Module: Reform::Form::Composition::ClassMethods
- Defined in:
- lib/reform/form/composition.rb
Instance Method Summary collapse
-
#model(main_model, options = {}) ⇒ Object
Same as ActiveModel::model but allows you to define the main model in the composition using
:on
. -
#model_class ⇒ Object
include Reform::Form::ActiveModel::ClassMethods # ::model.
Instance Method Details
#model(main_model, options = {}) ⇒ Object
Same as ActiveModel::model but allows you to define the main model in the composition using :on
.
class CoverSongForm < Reform::Form
model :song, on: :cover_song
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/reform/form/composition.rb', line 24 def model(main_model, ={}) super composition_model = [:on] || main_model # FIXME: this should just delegate to :model as in FB, and the comp would take care of it internally. [:persisted?, :to_key, :to_param].each do |method| define_method method do model[composition_model].send(method) end end self end |
#model_class ⇒ Object
include Reform::Form::ActiveModel::ClassMethods # ::model.
15 16 17 |
# File 'lib/reform/form/composition.rb', line 15 def model_class # DISCUSS: needed? @model_class ||= Reform::Composition.from(representer_class) end |