How to create fixtures with foreign key alias in rails?
问题 I have two models, App and User , where an App has a creator who is a User . # app.rb class App < ActiveRecord::Base belongs_to :creator, class_name: 'User' end # user.rb class User < ActiveRecord::Base has_many :apps, foreign_key: "creator_id" end How do I create fixtures for this? I tried: # apps.yml myapp: name: MyApp creator: admin (User) # users.yml admin: name: admin But this doesn't work, since the relation is an aliased foreign key, not a polymorphic type. Omitting the (User) in the