开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜