mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 07:10:12 +01:00
activerecord associations do not act like a collection anymore, so convert to array first
before using map, collect, etc.
This commit is contained in:
parent
85cfa1c366
commit
49a09f36e8
4 changed files with 9 additions and 9 deletions
|
|
@ -9,10 +9,10 @@ module IsTaggable
|
|||
has_many :taggings, :as => :taggable
|
||||
has_many :tags, :through => :taggings do
|
||||
def to_s
|
||||
self.map(&:name).sort.join(Tag::JOIN_DELIMITER)
|
||||
self.to_a.map(&:name).sort.join(Tag::JOIN_DELIMITER)
|
||||
end
|
||||
def all_except_starred
|
||||
self.reject{|tag| tag.name == Todo::STARRED_TAG_NAME}
|
||||
self.to_a.reject{|tag| tag.name == Todo::STARRED_TAG_NAME}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ module IsTaggable
|
|||
|
||||
# Transactions may not be ideal for you here; be aware.
|
||||
Tag.transaction do
|
||||
current = tags.map(&:name)
|
||||
current = tags.to_a.map(&:name)
|
||||
_add_tags(list - current)
|
||||
_remove_tags(current - list)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue