Skip to content

Commit

Permalink
Merge pull request #583 from twalpole/edge
Browse files Browse the repository at this point in the history
Update for rails edge (4.2)
  • Loading branch information
seuros committed Aug 29, 2014
2 parents 41a5edb + f7fe2e4 commit 585aadd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch.
* [@ProGM Support for custom parsers for tags](https://github.com/mbleigh/acts-as-taggable-on/pull/579)

* Fixes
* [@twalpole Update for rails edge (4.2)]
* Performance
* Misc

Expand Down
18 changes: 15 additions & 3 deletions lib/acts_as_taggable_on/taggable/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ def process_dirty_object(context, new_list)
if changed_attributes.include?(attrib)
# The attribute already has an unsaved change.
old = changed_attributes[attrib]
changed_attributes.delete(attrib) if old.to_s == value.to_s
@changed_attributes.delete(attrib) if old.to_s == value.to_s
else
old = tag_list_on(context)
if self.class.preserve_tag_order
changed_attributes[attrib] = old if old.to_s != value.to_s
@changed_attributes[attrib] = old if old.to_s != value.to_s
else
changed_attributes[attrib] = old.to_s if old.sort != ActsAsTaggableOn.default_parser.new(value).parse.sort
@changed_attributes[attrib] = old.to_s if old.sort != ActsAsTaggableOn.default_parser.new(value).parse.sort
end
end
end
Expand Down Expand Up @@ -420,6 +420,18 @@ def save_tags

private

# Filters the tag lists from the attribute names.
def attributes_for_update(attribute_names)
tag_lists = tag_types.map {|tags_type| "#{tags_type.to_s.singularize}_list"}
super.delete_if {|attr| tag_lists.include? attr }
end

# Filters the tag lists from the attribute names.
def attributes_for_create(attribute_names)
tag_lists = tag_types.map {|tags_type| "#{tags_type.to_s.singularize}_list"}
super.delete_if {|attr| tag_lists.include? attr }
end

##
# Override this hook if you wish to subclass {ActsAsTaggableOn::Tag} --
# context is provided so that you may conditionally use a Tag subclass
Expand Down

0 comments on commit 585aadd

Please sign in to comment.