baban / flextures

This plug-in can load and dump test data in databases, loading function is very flexible, dump function is very simple
MIT License
22 stars 3 forks source link

rails3.2環境でidの無いテーブルに読み込みをかけるとエラーメッセージが出る #4

Closed baban closed 12 years ago

baban commented 12 years ago

DEPRECATION WARNING: You're trying to create an attribute id'. Writing arbitrary attributes on a model is deprecated. Please just useattr_writer` etc. (called from write_attribute at /Users/matsubaramasanao/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.2/lib/active_record/attribute_methods/write.rb:32)

baban commented 12 years ago

以下の症状で発現するようです

・テーブル名からモデルの名前が推測できない ・プライマリキーとして、idというカラムが存在しない

その場合、テーブル名からモデル名が推測できるようになればいいので flextures.factory.rbに以下のように記述して、テーブル名からモデル名が推測できるようにすれば解決します

Flextures::Factory.define :d_questions, Question do |f| end