# Freshly starting with Rails.. Scaffold issue

**URL:** <https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771>\
**Category:** Rails\
**Created:** [December 12, 2007, 12:14am UTC](https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771 "2007-12-12T00:14:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![geoffw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://www.ruby-forum.com/u/geoffw)\
**Post date:** [December 12, 2007, 12:14am UTC](https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771/1 "2007-12-12T00:14:42Z")

</div>

I understand that scaffolding has been removed in 2.x but is available  
as a generated script.

I’ve generated the scaffold and inserted some data into the DB by hand  
(1 record).

The scaffold pages ( [http://ruby.geeklan.com/public/products/](http://ruby.geeklan.com/public/products/) ) don’t  
show anything and the log file doesn’t indicate anything (useful to me,  
anyway, looks successful all the way through).

Am I missing something obvious or is there other information i can  
provide?

I’m an experienced PHP Developer (10+ years), but this is totally new to  
me. Even the basics barely apply.

---

<div class="post-metadata">

**Author:** ![geoffw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://www.ruby-forum.com/u/geoffw)\
**Post date:** [December 12, 2007, 12:30am UTC](https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771/2 "2007-12-12T00:30:02Z")

</div>

Geoff W. wrote:

> I understand that scaffolding has been removed in 2.x but is available  
> as a generated script.
> 
> I’ve generated the scaffold and inserted some data into the DB by hand  
> (1 record).
> 
> The scaffold pages ( [http://ruby.geeklan.com/public/products/](http://ruby.geeklan.com/public/products/) ) don’t  
> show anything and the log file doesn’t indicate anything (useful to me,  
> anyway, looks successful all the way through).
> 
> Am I missing something obvious or is there other information i can  
> provide?
> 
> I’m an experienced PHP Developer (10+ years), but this is totally new to  
> me. Even the basics barely apply.

check if you have a non NULL field in the database.

---

<div class="post-metadata">

**Author:** ![geoffw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://www.ruby-forum.com/u/geoffw)\
**Post date:** [December 12, 2007, 12:46am UTC](https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771/3 "2007-12-12T00:46:15Z")

</div>

This is my current table layout:

CREATE TABLE `products` (  
`id` int(11) NOT NULL auto\_increment,  
`title` varchar(100) default NULL,  
`description` text,  
`image_url` varchar(200) default NULL,  
`price` decimal(10,2) default NULL,  
PRIMARY KEY (`id`)  
) ENGINE=MyISAM AUTO\_INCREMENT=3 DEFAULT CHARSET=utf8 AUTO\_INCREMENT=3 ;

I’d assume this should work, it’s out of the Agile Web Dev w/ Rails book  
(Tad old, but I’ve managed to get this far).

---

<div class="post-metadata">

**Author:** ![geoffw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://www.ruby-forum.com/u/geoffw)\
**Post date:** [December 12, 2007, 1:46am UTC](https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771/4 "2007-12-12T01:46:25Z")

</div>

Ryan B. wrote:

> Your form is empty for your new products link.

That’s what doesn’t make sense to me. I generated this using:

scripts/generate scaffold Product

I would assume the scaffold generation process would take care of the  
forms and general format of the page. Is this not true? Seems like that  
would defeat the purpose of even offering the ability to generate a  
scaffold if it doesn’t actually work.

Looking at the Listing products page which was generated, it has nothing  
to show the product fields anywhere.

I added a line as such:

Product ID: \<%= product.id %\>

And it does print the product ID. This looks like a bug to me. I can  
reproduce this when generating the scaffold for any table.

---

<div class="post-metadata">

**Author:** ![geoffw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://www.ruby-forum.com/u/geoffw)\
**Post date:** [December 12, 2007, 2:45am UTC](https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771/5 "2007-12-12T02:45:04Z")

</div>

Aha! So you’ve gone script/generate scaffold product!

The correct way is to define which fields you would like defined within  
the  
scaffold:

script/generate scaffold title:string description:text image\_url:string  
price:integer  
On Dec 12, 2007 10:16 AM, Geoff W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ) ENGINE=MyISAM AUTO\_INCREMENT=3 DEFAULT CHARSET=utf8 AUTO\_INCREMENT=3 ;
> 
> ## I’d assume this should work, it’s out of the Agile Web Dev w/ Rails book (Tad old, but I’ve managed to get this far).
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![geoffw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://www.ruby-forum.com/u/geoffw)\
**Post date:** [December 12, 2007, 2:59am UTC](https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771/6 "2007-12-12T02:59:02Z")

</div>

Ryan B. wrote:

> Aha! So you’ve gone script/generate scaffold product!
> 
> The correct way is to define which fields you would like defined within  
> the  
> scaffold:
> 
> script/generate scaffold title:string description:text image\_url:string  
> price:integer
> 
> –  
> Ryan B.  
> [http://www.frozenplague.net](http://www.frozenplague.net)

I see now!

Thank you very much, Mr. Bigg! This should help me greatly on my path to  
Enlightenment. Enrailsment?

---

<div class="post-metadata">

**Author:** ![geoffw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://www.ruby-forum.com/u/geoffw)\
**Post date:** [December 12, 2007, 3:07am UTC](https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771/7 "2007-12-12T03:07:16Z")

</div>

It’s not a bug, it’s a “feature” of Rails 2.0.

I wouldn’t encourage you to use script/generate scaffold anyway.

On Dec 12, 2007 11:16 AM, Geoff W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## forms and general format of the page. Is this not true? Seems like that And it does print the product ID. This looks like a bug to me. I can reproduce this when generating the scaffold for any table.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![geoffw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://www.ruby-forum.com/u/geoffw)\
**Post date:** [December 12, 2007, 1:03am UTC](https://www.ruby-forum.com/t/freshly-starting-with-rails-scaffold-issue/122771/8 "2007-12-12T01:03:21Z")

</div>

Your form is empty for your new products link.

Are you sure you put the data in the right table?

Try doing \<%= Product.count %\> which will give a number of how many  
records  
are in the products table if you have a Product model  
On Dec 12, 2007 9:44 AM, Geoff W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Am I missing something obvious or is there other information i can  
> provide?
> 
> ## I’m an experienced PHP Developer (10+ years), but this is totally new to me. Even the basics barely apply.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!
