lib/reform/form/active_model.rb in reform-0.2.4 vs lib/reform/form/active_model.rb in reform-0.2.5
- old
+ new
@@ -53,21 +53,31 @@
self
end
end
end
+
module ClassMethods
+ # this module is only meant to extend (not include). # DISCUSS: is this a sustainable concept?
+ def self.extended(base)
+ base.class_eval do
+ extend Hooks::InheritableAttribute
+ inheritable_attr :model_options
+ end
+ end
+
+
# Set a model name for this form if the infered is wrong.
#
# class CoverSongForm < Reform::Form
# model :song
def model(main_model, options={})
- @model_options = [main_model, options] # FIXME: make inheritable!
+ self.model_options = [main_model, options]
end
def model_name
- if @model_options
- form_name = @model_options.first.to_s.camelize
+ if model_options
+ form_name = model_options.first.to_s.camelize
else
form_name = name.sub(/Form$/, "")
end
active_model_name_for(form_name)