Closed miletbaker closed 3 years ago
@miletbaker Thank you for your comment! According to your suggestion, it looks better the newly defined scopes expect single parameter since it can support both cases of array and string.
Ok, I will try to update the gem with this way. please be patient..
By the way, the bellow one is what you want to show in the third example, right?
User.with_all_tags *("awesome, slick").split(",").collect(&:strip)
Yes you are correct thanks.
@miletbaker I updated to 0.3.0. Please try it out.
Closing. No activity.
@tmiyamon firstly thanks for the excellent gem, I'm seriously considering pulling acts_as_taggable_on as this is more suited and performs faster for our needs.
One question is in regards to the scopes that get added by acts_as_taggable_array_on. You have designed it to expect multiple parameters when searching for records that match with_any or without_any etc. I'm not sure of a time when you would search for records this way unless you are on the console as most input data would be in a string of tags to search. For example from a search form the user would comma separate the tags to search for.
As you have specified *tags on the scope parameters, so with multiple tags you need to call the method with multiple parameters, which is fine in the console, i.e.:
User.with_all_tags "awesome", "slick"
But most of the time I would have though you will have your list of tags to search on in an array or string. So for example if you want to search with an array of tags you need to call this as follows:
User.with_all_tags *["awesome", "slick"]
Note: the * before the array
If you want to search with a string of comma separated tags, you would need to call
User.with_all_tags *("awesome, slick").join(",")collect(&:strip))
Am I missing something, and/or it may be worth documenting this? Also it might be better to move this / change the way these are called in the scope, though I guess any change like this would break any existing usage?
Just some thoughts anyway, I thought I would start the discussion and for now I'll use the workarounds above.
Jon