Yep. _id is a ''magic'' column name.
To a certain extent, Rails assumes that blah_id is a foreign key
reference to a table called ''blahs'', which has a model defined
in blah.rb.
It does this because unfortunately SQL doesn''t go into enough detail
about exactly how foreign keys will be used. It just defines them and
leaves it up to the developer.
You can still call something whatever_id, it just won''t appear in the
scaffolding. If you write code that displays its value, it will be
displayed.
Personally, I move past the scaffolding after only a few minutes of work
in most cases, so this limitation hasn''t really bothered me.
D''Andrew Thompson wrote:> This has probably been covered somewhere (at least not in my initial
> search through the list archives):
>
> I noticed that if I name a table column using "_id" at the end
(e.g.
> "cat_id"), generating the scaffolding and/or refreshing does not
> create the item on any of the forms. But by changing the name from
> "cat_id" to "cat_num" the itme was appropriately
scaffold.
>
> Any ideas...
>
> Does Rails specifically handle "id" (in any form) uniquely in the
model layer?