質問

Basically I would like to add the ability to vote on tags, so I would like to have a priority column for each different model's tag.

Any ideas about how to do this?

I suspect I need to make a new migration, but I don't know what to make it for. What would the migration be?

Thanks!

役に立ちましたか?

解決

As I remember, acts_as_taggable creates a table called tags, so you add a field to that table:

rails g migration add_votes_to_tag votes:integer

and add your logic to vote on tag.

P.S. Not sure if I understood correctly your question.

他のヒント

If you want to extend the regular usage of the tag class, seems to be the case, and create a special case for those tags that needs to be counted you can rely on a hook method from the core named [find_or_create_tags_from_list_with_context][1]

class Company < ActiveRecord::Base
    acts_as_taggable_on :markets, :locations

    def find_or_create_tags_from_list_with_context(tag_list, context)
        if context.to_sym == :markets
            MarketTag.find_or_create_all_with_like_by_name(tag_list)
        else
            super
        end
    end
end
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top