Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign newly create tags to owner #982

Open
chrisgeek opened this issue Jan 19, 2020 · 0 comments
Open

Assign newly create tags to owner #982

chrisgeek opened this issue Jan 19, 2020 · 0 comments

Comments

@chrisgeek
Copy link

Hi, great work on the gem, I am working with Active Admin and added the acts_as_taggable_on gem, problem is two models, templates and accounts, I want templates to be taggable while tags will be scoped to accounts. With Active Admin I have can create a tag without tagging it to template which is what I want, but the problem is, I need to be able to assign an account as the owner of the newly created tag, I have tried using this example from the wiki,
@some_user.tag(@some_photo, :with => "paris, normandy", :on => :locations)
but it only means an owner can only be added after an object has been tagged but I want to add an owner after creating the tag. below is the code I where I tried to add an owner to the tag after creating it.

ActiveAdmin.register ActsAsTaggableOn::Tag, as: "Tag" do
controller do
    def create
      super
      acct = Account.last.tag(params[:acts_as_taggable_on_tag])
    end
  end
end

Account model

class Account < ApplicationRecord
  acts_as_tagger
end

Template Model

class ItemTemplate < ItemParent
  # after_save :set_tag_owner
  acts_as_taggable
end

Or does it mean a tag can't be assigned an owner unless it has been tagged to an object ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant