Update owner tags via form

前端 未结 7 1838
Happy的楠姐
Happy的楠姐 2020-12-18 01:26

I would like to uniquely use owner tags in my app. My problem is that when I create / update a post via a form I only have f.text_field :tag_list which only upd

7条回答
  •  无人及你
    2020-12-18 01:52

    the set_tag_owner before_save worked for me. But as bcb mentioned, I had to add a condition (tag_list_changed?) to prevent the tags from being deleted on update:

    def set_tag_owner
      if tag_list_changed?
        set_owner_tag_list_on(account, :tags, tag_list)
        self.tag_list = nil
      end
    end
    

提交回复
热议问题