The Zach Chadwick

  • Archive
  • RSS

acts_as_taggable_on :weirdness

I’ve spent a large part of my day tracking down a very weird behavior in the acts_as_taggable_on plugin.  I am using it to tag articles with multiple categories. In general, it’s awesome.

The weirdness comes in with the specific tags that I am using.  For example, one article might be tagged “DHCP” as it refers to that protocol.  However, as soon as I created a “DHCPv6” tag, my Article.tagged_with("DHCP") stopped working.

I tracked it down to Line 161 which builds a list of tags like the one you are looking for, and if it’s a different length than your tag list, it returns a query condition that will always fail, thus preventing any results. Why does it do that?

The solution, was to specify :all => true in my Article.tagged_with call.

    • #programming
    • #rails
    • #ruby
  • 2 years ago
  • Permalink
  • Share
    Tweet

About

Musician, programmer, and occasional photographer. This is my small attempt to help other people out with some of the same problems I have run into along the way.

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr