Why does scaffold ignores some fields?

Hello,

somehow the ‘scaffold’ method does not emits HTML fields for all the
fields
of my models. For example, this simple controller:

class CatalogController < ApplicationController
scaffold :fact
end

and a model backed by (sqlite3, tested also with mysql)

create table “facts” (
“id” integer primary key autoincrement,
“type” varchar not null,
“device_id” integer not null,
“stated_on” date not null,
“created_at” datetime not null,
“updated_at” datetime not null,
“approved” boolean default false
);

produces HTML fields only for “Stated on”, “Created at”, “Updated at”
and “Approved”. “type” and “device_id” are ignored. Why?

Simple.

type is a “reserved word” in Ruby. Not really a reserved word like in
other language but a synonym for the Object.class method. Since
everything an object in Ruby…

deviced_id is maybe ignored because it is a foreign key. If you want to
display the linked records, you should do it by yourself by customizing
the scaffold and use select or collection_select.

Nicolas.

Gioele wrote:

Hello,

somehow the ‘scaffold’ method does not emits HTML fields for all the
fields
of my models. For example, this simple controller:

class CatalogController < ApplicationController
scaffold :fact
end

and a model backed by (sqlite3, tested also with mysql)

create table “facts” (
“id” integer primary key autoincrement,
“type” varchar not null,
“device_id” integer not null,
“stated_on” date not null,
“created_at” datetime not null,
“updated_at” datetime not null,
“approved” boolean default false
);

produces HTML fields only for “Stated on”, “Created at”, “Updated at”
and “Approved”. “type” and “device_id” are ignored. Why?