# Scaffold (form) for single record

**URL:** <https://www.ruby-forum.com/t/scaffold-form-for-single-record/175333>\
**Category:** Rails\
**Created:** [September 11, 2009, 12:36pm UTC](https://www.ruby-forum.com/t/scaffold-form-for-single-record/175333 "2009-09-11T12:36:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [September 11, 2009, 12:36pm UTC](https://www.ruby-forum.com/t/scaffold-form-for-single-record/175333/1 "2009-09-11T12:36:03Z")

</div>

I am looking for a sort of scaffolding (because the schema of the  
individual table whose individual record I do not know until runtime)  
for putting into a div to be displayed in say, redbox. Does anyone  
have anything along the lines for that they might recommend? Thanks,  
RVince

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [September 11, 2009, 6:36pm UTC](https://www.ruby-forum.com/t/scaffold-form-for-single-record/175333/2 "2009-09-11T18:36:40Z")

</div>

Hey RVince

Creating tables at runtime sounds really messy - have you considered  
other options?

For example, using serialize in your models and storing attributes as  
a hash:

class Product

serialize :attributes

end

@product = Product.new :name =\> “Canon Ixus”, :category =\>  
“Camera”, :attributes =\> { :price =\> $150, :battery\_life =\> “8  
hours”, … etc… }

Maybe this ‘virtual class’ approach isn’t best for your app but  
perhaps there are other, similar approaches?

Gavin

---

<div class="post-metadata">

**Author:** ![RVince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@RVince](https://www.ruby-forum.com/u/RVince)\
**Post date:** [September 11, 2009, 6:39pm UTC](https://www.ruby-forum.com/t/scaffold-form-for-single-record/175333/3 "2009-09-11T18:39:01Z")

</div>

attributes would likely screw up ActiveRecord though, that was silly  
of me. Perhaps another name like “virtual\_attributes” would be better.
