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!
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? On 23 mayo, 19:27, aupayo <cres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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!
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 <cresteb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > 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? > > > > On 23 mayo, 19:27, aupayo <cres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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! > > >-- ________________________ Steve Shepherd Mob:+64 (0) 27 4338154 Email: sargshep-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Analyst --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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) On 24 mayo, 18:35, aupayo <cres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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? > > On 23 mayo, 19:27,aupayo<cres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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!
# 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) On 24 mayo, 18:35, aupayo <cres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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? > > On 23 mayo, 19:27,aupayo<cres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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!