mardi 29 septembre 2015

Label references with custom foreign keys in rails fixtures

I have a lists class with a customized foreign_key

class List < ActiveRecord::Base
    belongs_to :user, foreign_key: 'author_id'

The table was created adding a reference and a foreign key as follows

add_reference :lists, :author, index: true
add_foreign_key :lists, :users, column: :author_id

Problem is, in my fixtures I'm trying to use label references but I keep getting a SQL exception
table lists has no column named author

lists.yml

list1:
    name: topchartsyea
    author: dude1

Any ideas? Is it even possible to use label references when using customized foreign keys like these?

Using rails 4.2.0

Aucun commentaire:

Enregistrer un commentaire