这是错误:
ActiveRecord::AssociationTypeMismatch in VideosController#update Topic(#2173382840) expected, got String(#2148246520)
这是来自这种方法:
def assign_topics
if @topic_names
self.topics = @topic_names.each do |name|
Topic.find_or_create_by_name(name)
end
end
end
这个错误是什么意思?当主题是我的模型时,我不明白存在类型“主题”......
答案 0 :(得分:5)
“each”返回原始数组或可枚举,尝试使用“map”而不是