Forum: Ruby on Rails how to edit a pluggin? (acts_as_taggable_on)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
aupayo (Guest)
on 2009-05-23 21:28
(Received via mailing list)
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!
aupayo (Guest)
on 2009-05-24 20:36
(Received via mailing list)
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?
Steve Shepherd (Guest)
on 2009-05-24 23:14
(Received via mailing list)
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> 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
aupayo (Guest)
on 2009-06-08 21:43
(Received via mailing list)
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)
aupayo (Guest)
on 2009-06-08 22:08
(Received via mailing list)
# 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)
This topic is locked and can not be replied to.