app/helpers/contents_helper.rb in common-content-0.0.2 vs app/helpers/contents_helper.rb in common-content-0.0.3

- old
+ new

@@ -15,10 +15,15 @@ # end # link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")}) # end def link_to_add_fields(name, f, association) - new_object = f.object.send(association).klass.new + begin + new_object = f.object.send(association).klass.new + rescue Exception => e + p e + end + new_object ||= ::Content.const_get(association.to_s.camelize).new id = new_object.object_id fields = f.fields_for(association, new_object, child_index: id) do |builder| render(partial: association.to_s.singularize + "_fields", locals: { f: builder }) end link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})