Update owner tags via form

前端 未结 7 1826
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 02:11

    Try using delegation:

    class User < ActiveRecord::Base
      acts_as_taggable_on
    end
    
    class Post < ActiveRecord::Base
      delegate :tag_list, :tag_list=, :to => :user
    end
    

    So when you save your posts it sets the tag on the user object directly.

提交回复
热议问题