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

fix owned ordered taggable bug #585

Merged
merged 1 commit into from
Sep 1, 2014
Merged

fix owned ordered taggable bug #585

merged 1 commit into from
Sep 1, 2014

Conversation

kfyodor
Copy link
Contributor

@kfyodor kfyodor commented Aug 31, 2014

Hi again guys.

I got an email from a dude who ran into a nasty bug.

For example you have an ordered taggable model:

class MyTaggable < ActiveRecord::Base
  acts_as_ordered_taggable
end

and a simple user model:

class User < AR::Base
  acts_as_tagger
end

Let's open rails console:

user = User.last
my_taggable = MyTaggable.last

# this model has already been tagged before
my_taggable.tags_from(user) # => ['tag1', 'tag2', 'tag3']

I chose tags and their order to get into this block

# then you wanna change tags and their order. 
@user.tag(@my_taggable, with: "tag3, tag2", on: :tags) #=> and you got....

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error at or near "0"
LINE 1: SELECT "tags".* FROM 0 INNER JOIN "taggings" ON "tags"."id" ...
                             ^

Because of this "from" method which is being called from Relation class instead of Array.

Here's a fix and a test that recreates this behaviour.

seuros added a commit that referenced this pull request Sep 1, 2014
@seuros seuros merged commit e30d15f into mbleigh:master Sep 1, 2014
@kfyodor
Copy link
Contributor Author

kfyodor commented Sep 1, 2014

@seuros Thanks for merging it quickly!

@seuros
Copy link
Collaborator

seuros commented Sep 1, 2014

version 3.4.1 published

tekniklr pushed a commit to tekniklr/acts-as-taggable-on that referenced this pull request Mar 19, 2021
…ip_bug_fix

fix owned ordered taggable bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants