My Application uses acts-as-taggable-on to tag Content
. The content belongs_to
a Company
.
Now all created tags should belong to the used company and not be visible to other companies.
How can i solve this with acts-as-taggable-on? As context i currently use :content
. Is in my case the company the Tagger (owner)?
Thanks for clarification.
I solved it by declaring Company
as the tagger.
class Company < ApplicationRecord
acts_as_tagger
end
Controller action looks like the following:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With