Rails fixtures magical columns doesn't work anymore
created some fixtures yesterday and they worked great. Today i'll tried to rerun these fixtures, but there seems to be a problem with the magical columns. Here's an example fixture:
hans:
prename: Hans
lastname: Meier
admission_date: <%= D开发者_开发问答ate.today %>
user: service_user
menu: non_veg
And this fixture relates in the following error:
ActiveRecord::StatementInvalid: PGError: ERROR: column "user" of relation "patients" does not exist
LINE 1: ...astname", "prename", "admission_date", "menu_id", "user") VA...
^
: INSERT INTO "patients" ("id", "lastname", "prename", "admission_date", "menu_id", "user") VALUES (615630666, 'Meier', 'Hans', '2011-02-24', 285998188, 'service_user')
So it tries to insert the values which are related fixtures into the database as plain data. Does anyone knows how to avoid that?
Solved it, forgot to add :foreign_key: 'user_id'
to the model.
Now the fixtures are generated appropriate.
精彩评论