作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下工厂定义。
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
我知道工厂定义的“关联”方法,例如: f.association:组,:工厂=>:组但我实际上有一个名为 association 的列。为我的列分配值的方式是什么?
更新:在 Maletor 的帖子之后,我想到了一种解决方法 - 谢谢 Maletor
我将其添加到我的状态模型中
alias_attribute :assoc, :association
现在我可以做
Factory.define :my_status , :parent => :status do |f|
f.assoc 'somthing_here'
f.alias 'somthing_here'
f.name 'somthing_here'
end
工作正常:)
最佳答案
您可以在 f.after_create
中分配它。虽然不那么优雅。重命名该列也不是一个坏主意。
关于ruby-on-rails - 工厂女孩 : 'association' named column overlap with Factory method named 'association' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7195523/
我是一名优秀的程序员,十分优秀!