在失败的rspec测试中追溯外键错误

时间:2013-02-13 01:30:19

标签: ruby-on-rails ruby-on-rails-3.2

呼!在对表名和列名进行一些迁移之后,我的一个rspec测试失败了,我无法将其追溯到导致它的原因。所以这是我的rspc测试由于其中的这一行而失败:

it { should belong_to(:key_performance_indicators) }

生成此错误:

  

1)KeyPerformanceInterval        失败/错误:它{should belongs_to(:key_performance_indicators)}          期望KeyPerformanceInterval具有名为key_performance_indicators的belongs_to关联(KeyPerformanceInterval)   没有key_performance_indicators_id外键。)

那我该如何追溯呢?这是我在课堂上讨论的课程:

class KeyPerformanceInterval < ActiveRecord::Base

  include ActiveModel::ForbiddenAttributesProtection

  belongs_to :key_performance_indicators

end

如果我们需要更多源代码,请告知我们,我会用它来更新问题。

1 个答案:

答案 0 :(得分:0)

好的, 在shoulda匹配器中我应该从表的名称中删除字符“s”,所以它应该是:

it { should belong_to(:key_performance_indicator) }
相关问题