app/models/viewable/form.rb in rails_admin_cms-0.0.2 vs app/models/viewable/form.rb in rails_admin_cms-0.0.3

- old
+ new

@@ -11,20 +11,12 @@ accepts_nested_attributes_for :structure, allow_destroy: true has_unlocalized_fields :structure class << self - def names - @_names ||= CMS.dir_names 'app/views/cms/forms' - end - - def static_names - @_static_names ||= CMS.rb_names 'app/models/form' - end - def static?(name) - name.in? static_names + name.in? Naming::Viewable::Form.static_names end def not_static?(name) !static?(name) end @@ -33,14 +25,23 @@ def form_name @_form_name ||= view_path.split('/')[-2] end def static? - form_name.in? self.class.static_names + form_name.in? Naming::Viewable::Form.static_names end def not_static? !static? + end + + def fetch_row(form) + if structure.nil? + create_structure!(viewable: self, email: ::Form::Email.new) + end + attributes = form.attributes + attributes['structure_id'] = structure_id + rows.build(attributes) end private def uuid_columns