Tuesday, September 8, 2009

Using a factory name that doesn't correspond to a model


# Model

class GradeScaleRange < ActiveRecord::Base
end

# Factory

# Normally case -> OK!
Factory.define :grade_scale_range do
end

# This will scream!
Factory.define :grade_scale_range_a do
end

# Correct it with class name
Factory.define :grade_scale_range_a, :class => 'grade_scale_range' do
end

# Although the below seems ok in documentation. It will spew "dup NilClass" error
Factory.define :grade_scale_range_a, :class => GradeScaleRange do
end

No comments:

Blog Archive