Module: Reform::Form::ActiveModel::ClassMethods
- Defined in:
- lib/reform/form/active_model.rb
Class Method Summary collapse
-
.extended(base) ⇒ Object
this module is only meant to extend (not include).
Instance Method Summary collapse
-
#model(main_model, options = {}) ⇒ Object
Set a model name for this form if the infered is wrong.
- #model_name ⇒ Object
Class Method Details
.extended(base) ⇒ Object
this module is only meant to extend (not include). # DISCUSS: is this a sustainable concept?
64 65 66 67 68 69 |
# File 'lib/reform/form/active_model.rb', line 64 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
76 77 78 |
# File 'lib/reform/form/active_model.rb', line 76 def model(main_model, ={}) self. = [main_model, ] end |
#model_name ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/reform/form/active_model.rb', line 80 def model_name if form_name = .first.to_s.camelize else form_name = name.sub(/(::)?Form$/, "") # Song::Form => "Song" end active_model_name_for(form_name) end |