# Displaying the id field

**URL:** <https://www.ruby-forum.com/t/displaying-the-id-field/122509>\
**Category:** Rails\
**Created:** [December 8, 2007, 1:43pm UTC](https://www.ruby-forum.com/t/displaying-the-id-field/122509 "2007-12-08T13:43:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 8, 2007, 1:43pm UTC](https://www.ruby-forum.com/t/displaying-the-id-field/122509/1 "2007-12-08T13:43:23Z")

</div>

When the browser is pointed to [http://localhost:3000/feeds](http://localhost:3000/feeds) there’s a  
CRUD interface. However, the interface doesn’t display all of the  
fields  
defined at \<[http://strawr.googlecode.com/svn/trunk/db/](http://strawr.googlecode.com/svn/trunk/db/)  
migrate/001\_feeds.rb\>.

I’ve done “rake db:migrate VERSION=0 ; rake db:migrate” and, also:

thufir@arrakis ~/Desktop/strawr/db $  
thufir@arrakis ~/Desktop/strawr/db $ ll  
total 20  
-rw-r–r-- 1 thufir users 9216 Dec 8 04:29 development.sqlite3  
drwxr-xr-x 3 thufir users 4096 Dec 8 04:29 migrate  
-rw-r–r-- 1 thufir users 1430 Dec 8 04:29 schema.rb  
thufir@arrakis ~/Desktop/strawr/db $  
thufir@arrakis ~/Desktop/strawr/db $ sqlite3 development.sqlite3  
SQLite version 3.4.1  
Enter “.help” for instructions  
sqlite\> .schema  
CREATE TABLE categories (“id” INTEGER PRIMARY KEY NOT NULL, “parent\_num”  
integer DEFAULT NULL, “title” varchar(255) DEFAULT NULL, “feed\_id”  
integer DEFAULT NULL);  
CREATE TABLE feeds (“id” INTEGER PRIMARY KEY NOT NULL, “title” varchar  
(255) DEFAULT NULL, “location” varchar(255) DEFAULT NULL, “category\_id”  
integer DEFAULT NULL, “item\_id” integer DEFAULT NULL);  
CREATE TABLE items (“id” INTEGER PRIMARY KEY NOT NULL, “title” varchar  
(255) DEFAULT NULL, “is\_read” integer DEFAULT NULL, “link” varchar(255)  
DEFAULT NULL, “pub\_date” varchar(255) DEFAULT NULL, “description”  
varchar  
(255) DEFAULT NULL, “feed\_id” integer DEFAULT NULL);  
CREATE TABLE nodes (“id” INTEGER PRIMARY KEY NOT NULL, “obj\_num” integer  
DEFAULT NULL, “norder” varchar(255) DEFAULT NULL, “type” varchar(255)  
DEFAULT NULL);  
CREATE TABLE posts (“id” INTEGER PRIMARY KEY NOT NULL, “post” varchar  
(255) DEFAULT NULL);  
CREATE TABLE schema\_info (version integer);  
sqlite\>  
sqlite\> .quit  
thufir@arrakis ~/Desktop/strawr/db $  
thufir@arrakis ~/Desktop/strawr/db $

Clearly the “feeds” table has “item\_id” as a field; so why doesn’t it  
show in the CRUD? Perhaps I need to undo and then redo the  
scaffolding?

based on \<[http://strawr.googlecode.com/svn/trunk/app/views/feeds/](http://strawr.googlecode.com/svn/trunk/app/views/feeds/)  
show.rhtml\>, I don’t see why all the fields for “feeds” aren’t being  
displayed ☹

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 8, 2007, 2:09pm UTC](https://www.ruby-forum.com/t/displaying-the-id-field/122509/2 "2007-12-08T14:09:44Z")

</div>

On 8 Dec 2007, at 12:41, Thufir wrote:

> When the browser is pointed to [http://localhost:3000/feeds](http://localhost:3000/feeds) there’s a  
> CRUD interface. However, the interface doesn’t display all of the  
> fields  
> defined at \<[http://strawr.googlecode.com/svn/trunk/db/](http://strawr.googlecode.com/svn/trunk/db/)  
> migrate/001\_feeds.rb\>.

Scaffolding just iterates over content\_columns. If you look a the doc  
for content\_columns you’ll see that it doesn’t include columns ending  
in \_id

Fred

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 8, 2007, 8:34pm UTC](https://www.ruby-forum.com/t/displaying-the-id-field/122509/3 "2007-12-08T20:34:22Z")

</div>

On Sat, 08 Dec 2007 13:09:05 +0000, Frederick C. wrote:

> Scaffolding just iterates over content\_columns. If you look a the doc  
> for content\_columns you’ll see that it doesn’t include columns ending in  
> \_id

Yes, you’re absolutely correct (I even looked at the API after posting  
this last night). I tried a few variations, and did some light  
googling,  
but didn’t find a way to get it iterate over all fields.

Can I just change that one line so that it shows all of the fields when  
doing any of the CRUD actions?

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 8, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/displaying-the-id-field/122509/4 "2007-12-08T20:57:15Z")

</div>

On 8 Dec 2007, at 19:33, Thufir wrote:

> this last night). I tried a few variations, and did some light  
> googling,  
> but didn’t find a way to get it iterate over all fields.
> 
> Can I just change that one line so that it shows all of the fields  
> when  
> doing any of the CRUD actions?

does using Model.columns do what you want?

Fred

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 9, 2007, 8:03am UTC](https://www.ruby-forum.com/t/displaying-the-id-field/122509/5 "2007-12-09T08:03:48Z")

</div>

On Sat, 08 Dec 2007 19:57:04 +0000, Frederick C. wrote:

> does using Model.columns do what you want?

I still get the same result after using Feed.columns ☹

[http://strawr.googlecode.com/svn/trunk/app/views/feeds/list.rhtml](http://strawr.googlecode.com/svn/trunk/app/views/feeds/list.rhtml)

The database appears fine:

thufir@arrakis ~/Desktop/strawr/db $  
thufir@arrakis ~/Desktop/strawr/db $  
thufir@arrakis ~/Desktop/strawr/db $  
thufir@arrakis ~/Desktop/strawr/db $ sqlite3 development.sqlite3  
SQLite version 3.4.1  
Enter “.help” for instructions  
sqlite\> .schema  
CREATE TABLE categories (“id” INTEGER PRIMARY KEY NOT NULL, “parent\_num”  
integer DEFAULT NULL, “title” varchar(255) DEFAULT NULL, “feed\_id”  
integer DEFAULT NULL);  
CREATE TABLE feeds (“id” INTEGER PRIMARY KEY NOT NULL, “title” varchar  
(255) DEFAULT NULL, “location” varchar(255) DEFAULT NULL, “category\_id”  
integer DEFAULT NULL, “item\_id” integer DEFAULT NULL);  
CREATE TABLE items (“id” INTEGER PRIMARY KEY NOT NULL, “title” varchar  
(255) DEFAULT NULL, “is\_read” integer DEFAULT NULL, “link” varchar(255)  
DEFAULT NULL, “pub\_date” varchar(255) DEFAULT NULL, “description”  
varchar  
(255) DEFAULT NULL, “feed\_id” integer DEFAULT NULL);  
CREATE TABLE nodes (“id” INTEGER PRIMARY KEY NOT NULL, “obj\_num” integer  
DEFAULT NULL, “norder” varchar(255) DEFAULT NULL, “type” varchar(255)  
DEFAULT NULL);  
CREATE TABLE posts (“id” INTEGER PRIMARY KEY NOT NULL, “post” varchar  
(255) DEFAULT NULL);  
CREATE TABLE schema\_info (version integer);  
sqlite\>  
sqlite\> .quit  
thufir@arrakis ~/Desktop/strawr/db $

-Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 10, 2007, 10:42am UTC](https://www.ruby-forum.com/t/displaying-the-id-field/122509/6 "2007-12-10T10:42:28Z")

</div>

On Sun, 09 Dec 2007 11:04:01 +0000, Frederick C. wrote:

> Well you’ve still got a content\_columns at the top of your page. Other  
> than that I don’t see why it wouldn’t work (although you wouldn’t see  
> anything if the \_id columns were null)

Doh, fixed that; thanks. The item\_id field for a row in the feeds table  
will be null until I can edit that field; for instance, by displaying  
the  
field.

Won’t it show: “item\_id: NULL” as it does for other fields?

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 9, 2007, 12:04pm UTC](https://www.ruby-forum.com/t/displaying-the-id-field/122509/7 "2007-12-09T12:04:47Z")

</div>

On 9 Dec 2007, at 07:02, Thufir wrote:

> On Sat, 08 Dec 2007 19:57:04 +0000, Frederick C. wrote:
> 
> > does using Model.columns do what you want?
> 
> I still get the same result after using Feed.columns ☹
> 
> [http://strawr.googlecode.com/svn/trunk/app/views/feeds/list.rhtml](http://strawr.googlecode.com/svn/trunk/app/views/feeds/list.rhtml)

Well you’ve still got a content\_columns at the top of your page. Other  
than that I don’t see why it wouldn’t work (although you wouldn’t see  
anything if the \_id columns were null)

Fred

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 10, 2007, 10:51am UTC](https://www.ruby-forum.com/t/displaying-the-id-field/122509/8 "2007-12-10T10:51:15Z")

</div>

On 10 Dec 2007, at 09:36, Thufir wrote:

> will be null until I can edit that field; for instance, by  
> displaying the  
> field.
> 
> Won’t it show: “item\_id: NULL” as it does for other fields?

no. It would show nil.to\_s (ie blank), although you should of course  
get the column headings.

Fred
