Sha256: dc7e635cdbb44db9a2e6a083a0f201fa937756846f9351af97c2ac4b7532d37a
Contents?: true
Size: 558 Bytes
Versions: 5
Compression:
Stored size: 558 Bytes
Contents
module Tags extend ActiveSupport::Concern included do has_many :taggings, :as => :taggable has_many :tags, :through => :taggings attr_accessor :tag_list after_save :update_tags! end def update_tags! unless tag_list.nil? self.tags = [] used_tags = [] tag_list.split(',').each do |name| name.strip! if !used_tags.include?(name) && name.present? used_tags << name tag = Tag.find_or_create_by(:name => name) self.tags << tag end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems