Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在使用范围(tagger?)类型和上下文上充当标记人_Ruby On Rails_Acts As Taggable On - Fatal编程技术网

Ruby on rails 在使用范围(tagger?)类型和上下文上充当标记人

Ruby on rails 在使用范围(tagger?)类型和上下文上充当标记人,ruby-on-rails,acts-as-taggable-on,Ruby On Rails,Acts As Taggable On,我的应用程序使用作为标记来标记内容。内容属于a公司 现在,所有创建的标签都应该属于使用过的公司,其他公司看不到 我怎样才能用acts as taggable on解决这个问题?作为上下文,我当前使用:content。在我的情况下,公司是标记者(所有者)吗 感谢您的澄清。我通过宣布公司为标记人解决了这个问题 class Company < ApplicationRecord acts_as_tagger end def create if params[:content].has_

我的应用程序使用作为标记来标记
内容
。内容
属于
a
公司

现在,所有创建的标签都应该属于使用过的公司,其他公司看不到

我怎样才能用acts as taggable on解决这个问题?作为上下文,我当前使用
:content
。在我的情况下,公司是标记者(所有者)吗


感谢您的澄清。

我通过宣布
公司
为标记人解决了这个问题

class Company < ApplicationRecord
  acts_as_tagger
end
def create
  if params[:content].has_key?(:content_tag_list)
    content_tag_list = params[:content][:content_tag_list]
    params[:content].delete(:content_tag_list)
  end

  @content = Content.new(content_params)
  if @content.save
    if content_tag_list
      @content.company.tag(@content, with: content_tag_list, on: :content_tags)
    end
    redirect_back fallback_location: your_path
  else
    render :new
  end
end