# How to edit a pluggin? (acts\_as\_taggable\_on)

**URL:** <https://www.ruby-forum.com/t/how-to-edit-a-pluggin-acts-as-taggable-on/168666>\
**Category:** Rails\
**Created:** [May 23, 2009, 7:28pm UTC](https://www.ruby-forum.com/t/how-to-edit-a-pluggin-acts-as-taggable-on/168666 "2009-05-23T19:28:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aupayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7ab992/32.png) [@aupayo](https://www.ruby-forum.com/u/aupayo)\
**Post date:** [May 23, 2009, 7:28pm UTC](https://www.ruby-forum.com/t/how-to-edit-a-pluggin-acts-as-taggable-on/168666/1 "2009-05-23T19:28:04Z")

</div>

Hello,

I’m trying to modificate the acts\_as\_taggable\_on pluggin, so when you  
search various tags (Eg: User.tagged\_with(“fish, cat”, :on  
=\> :animals), it looks for users with BOTH tags, not just one of them.

I have edited the file acts\_as\_taggable\_on.rb and I have changed the  
line:  
“conditions \<\< tags.map { |t| sanitize\_sql([”#{tags\_alias}.name  
LIKE ?", t]) }.join(" OR “)”  
with  
““conditions \<\< tags.map { |t| sanitize\_sql([”#{tags\_alias}.name  
LIKE ?”, t]) }.join(" AND “)”.  
but when I execute the search, the sql sentence that is executed is  
the same than before.

I just restarted the console after doing the changes, do I have to do  
something else so the changes take effect? (I installed the plugin  
through GemPlugins)

Or maybe I’m editing the wrong line?..if someone has done this before  
please correct me if I’m wrong!

Thanks!

---

<div class="post-metadata">

**Author:** ![aupayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7ab992/32.png) [@aupayo](https://www.ruby-forum.com/u/aupayo)\
**Post date:** [May 24, 2009, 6:36pm UTC](https://www.ruby-forum.com/t/how-to-edit-a-pluggin-acts-as-taggable-on/168666/2 "2009-05-24T18:36:34Z")

</div>

In case someone has the same problem:

I have executed:  
rake gems:unpack  
So now the plugin is in the vendors/gem directory inside my rails  
proyect and when I edit it there, the changes take effect.

However I haven’t been able to obtain the functionality that I was  
looking for in acts\_as\_taggable\_on with the change I made…any ideas?

---

<div class="post-metadata">

**Author:** ![aupayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7ab992/32.png) [@aupayo](https://www.ruby-forum.com/u/aupayo)\
**Post date:** [May 24, 2009, 9:14pm UTC](https://www.ruby-forum.com/t/how-to-edit-a-pluggin-acts-as-taggable-on/168666/3 "2009-05-24T21:14:01Z")

</div>

Try using the IN sql operator.  
Unless you are using wildcards i think in should work.

ie name IN (‘fish’,‘frog’)

You will need to change your code.

On 5/25/09, aupayo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> looking for in acts\_as\_taggable\_on with the change I made…any ideas?
> 
> > I have edited the file acts\_as\_taggable\_on.rb and I have changed the  
> > something else so the changes take effect? (I installed the plugin  
> > through GemPlugins)
> > 
> > Or maybe I’m editing the wrong line?..if someone has done this before  
> > please correct me if I’m wrong!
> > 
> > Thanks!

–

* * *

Steve Shepherd  
Mob:+64 (0) 27 4338154  
Email: removed\_email\_address@domain.invalid  
Analyst

---

<div class="post-metadata">

**Author:** ![aupayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7ab992/32.png) [@aupayo](https://www.ruby-forum.com/u/aupayo)\
**Post date:** [June 8, 2009, 7:43pm UTC](https://www.ruby-forum.com/t/how-to-edit-a-pluggin-acts-as-taggable-on/168666/4 "2009-06-08T19:43:56Z")

</div>

There is a funtion dot does this…I have seen it documented in the  
official site:

# Options:

```
    # :exclude - Find models that are not tagged with the given

```

tags  
# :match\_all - Find models that match all of the given tags,  
not just one  
# :conditions - A piece of SQL conditions to add to the  
query  
# :on - scopes the find to a context

Model.find\_tagged\_with(“tag1, tag2”, :on =\> :context1, :match\_all =\>  
true)

---

<div class="post-metadata">

**Author:** ![aupayo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7ab992/32.png) [@aupayo](https://www.ruby-forum.com/u/aupayo)\
**Post date:** [June 8, 2009, 8:08pm UTC](https://www.ruby-forum.com/t/how-to-edit-a-pluggin-acts-as-taggable-on/168666/5 "2009-06-08T20:08:14Z")

</div>

# Options:

```
    # :exclude - Find models that are not tagged with the given

```

tags  
# :match\_all - Find models that match all of the given tags,  
not just one  
# :conditions - A piece of SQL conditions to add to the  
query  
# :on - scopes the find to a context

Model.find\_tagged\_with(“tag1, tag2”, :on =\> :context1, :match\_all =\>  
true)
