Factory-girl: 'association' named column overlap with Factory method named 'association'
I have the following Factory definition.
Factory.define :status do |f|
end
Factory.define :my_status , :parent => :status do |f|
f.association 'something_here'
f.alias 'something_here'
f.name 'something_here'
end
I know about the factory defined 'association' method, something like: f.association :group, :factory => :group But I actually have a column named association. What will be the way to assign values to my column?
Update: One way to solve came to me after Maletor's post - Thanks Maletor
I added this to my status model
alias_attribute :assoc, :association
and now I can do
Factory.define :my_status , :parent => :status do |f|
f.assoc 'somthing_here'
f.alias 'somthing_here'
f.name 'somthin开发者_JAVA技巧g_here'
end
Works fine :)
You could assign it in an f.after_create
. Not as elegant though. Renaming the column might not be a bad idea either.
精彩评论