Ruby on rails 使用ActsAsTaggableOn重命名标记时出现问题

Ruby on rails 使用ActsAsTaggableOn重命名标记时出现问题,ruby-on-rails,ruby-on-rails-3,acts-as-taggable-on,Ruby On Rails,Ruby On Rails 3,Acts As Taggable On,以下是我的方法: def rename old_tag = params[:old_tag] new_tag = params[:new_tag] if old_tag != new_tag # find any articles that use the old tag Article.tagged_with(old_tag).each do |article| # give articles with the old tag the new tag

以下是我的方法:

def rename
  old_tag = params[:old_tag]
  new_tag = params[:new_tag]

  if old_tag != new_tag
    # find any articles that use the old tag
    Article.tagged_with(old_tag).each do |article|
      # give articles with the old tag the new tag
      article.tag_list.add(new_tag)
      # remove the old tag
      article.tag_list.remove(old_tag)
      article.save
    end
  end

  render :json => "#{old_tag} renamed to #{new_tag}"
end

我遇到的问题是,
.save
向文章中添加了一个新标记,但没有删除旧标记。

我面临的问题是更新标记将启动所有相关模型的验证,在我的例子中,验证失败是因为我的开发机器上没有图像,附件验证失败

要忽略验证,请执行以下操作:

article.save(:validate => false)

actsastaggaleon.remove_unused_tags=true,不应该在控制器中。该旧标记正在另一篇文章中使用吗?@andrew我在文档中找不到设置remove_unused_标记的位置,所以我把它放在那里,我猜它必须在初始化器中。我试图遍历所有使用旧标签的文章,并删除它们。@shane