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

Update for rails edge (4.2) fixes #580 #583

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 18 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,21 @@ def save_tags

private

# Filters the tag lists from the attribute names.
def attributes_for_update(attribute_names)
filter_tag_lists(super)
end

# Filters the tag lists from the attribute names.
def attributes_for_create(attribute_names)
filter_tag_lists(super)
end

def filter_tag_lists(attributes)
tag_lists = tag_types.map {|tags_type| "#{tags_type.to_s.singularize}_list"}
attributes.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