我有一个Post带有属性的模型published_at。但是,在 POST 请求 API 中要求将其分配为published,而不是published_at。所以在我的模型中,我像这样覆盖 setter 方法
def published=(value)
self.published_at = value
end
问题是,在我的 API 测试中,我使用 FactoryGirl 的attributes_for(:post)方法为 POST 请求生成属性,并且它使用旧published_at名称。如何解决此问题并使用published键生成属性,而不是published_at在我的模型中更改此属性的名称?