I have a table which includes an integer type column named “sequence”, which does not allow nulls. If I try to define the factory normally, FactoryGirl thinks I’m trying to set up a sequence rather than define a column name.
factory :my_table do
sequence 1
end
# NoMethodError: undefined method `to_sym' for 1:Fixnum
How can I set this up so that FactoryGirl recognizes it as a plain column, not a FactoryGirl sequence? What if I wanted to use an actual sequence to populate the column with unique incrementing integer values? I could see potentially having the same problem with a column named ‘trait’ or ‘association’. Incidentally, I’m using factory_girl 3.3.0 and rails 3.2.8.
Googling found this solution:
https://groups.google.com/forum/?fromgroups=#!topic/factory_girl/OriR9gXlMZI
If you then need to create a sequence and use it, see this cheat sheet:
http://cheat.errtheblog.com/s/factory_girl