Simon Grant wrote in post #968977:
I have a database table with over 100 fields, however I want my model
to include only a few fields so that every time I do a query/update, it
will only do so for those fields.
Is there a way to specify in a model to only use selected fields from a
table and ignore the rest?
If you want hard protection for reading and writing only
to a few columns, you could use a VIEW. In that way,
you would also stay with the default Rails behaviour for
that limited set of columns.
CREATE TABLE many_columns (c1 text, c2 text, c3 text, c4 text);
Query OK, 0 rows affected (0.00 sec)
INSERT INTO many_columns (c1,c2,c3,c4) VALUES ('t1', 't2', 't3',
Query OK, 1 row affected (0.00 sec)