mbleigh / acts-as-taggable-on
- Source
- Commits
- Network (91)
- Issues (9)
- Downloads (8)
- Wiki (1)
- Graphs
-
Branch:
master
-
Incorrectly process tag lists with two or more quotation marks.
See: http://gist.github.com/262434Comments
-
tagged_with returns all results when none found
4 comments Created 18 days ago by barmstrongIs anyone else seeing this?
When I pass tagged_with a tag that does not exist, it returns every record (instead of none).
>> Website.tagged_with("some tag that does not exist", :on=>:tags).size => 239 >> Website.count => 239Comments
barmstrong
Thu Dec 17 16:03:27 -0800 2009
| link
By the way, I'm using standard latest MySQL 5.0.67, and Rails 2.3.4 so that probably isn't the issue.
Same here, with Rails 2.3.5. Seems to caused by the yesterdays optimization in 79d460e
Yeah, sorry about that. I've fixed it and released a new version.
barmstrong
Fri Dec 18 13:07:28 -0800 2009
| link
Ahh cool, thanks for the quick response!
-
Hi,
is it possible to support friendly url like in this gem http://github.com/norman/friendly_id ?
Name of the tag instead of the id in the url (and in the searching etc.)
Thanks
PetrComments
I'm not completely sure, but can't you use friendly_id and acts-as-taggable-on together? Does calling
Tag.has_friendly_id :namefrom a rails initializer work? -
With this model code:
acts_as_taggable_on :categories
I get a model that supports self.categories. The tag context acts kind of like a has_many association. Good.
But when I add:
accepts_nested_attributes_for :categories
and POST a list of categories to the create action I get this exception deep in AR#new:
1)
ActiveRecord::AssociationTypeMismatch in 'PlacesController authenticated user should process categories parameter to create'
Tag(#2176796520) expected, got String(#2148246520)
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/associations/association_proxy.rb:263:inraise_on_type_mismatch' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/associations/association_collection.rb:320:inreplace' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/associations/association_collection.rb:320:ineach' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/associations/association_collection.rb:320:inreplace' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/associations.rb:1322:in `categories='It appears that the association is looking for Tag objects and won't accept the Strings I'm handing it.
Comments
Next, I tried:
accepts_nested_attributes_for :category_listBut that gave:
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/nested_attributes.rb:215:in `accepts_nested_attributes_for': No association found for name `category_list'. Has it been defined yet? (ArgumentError)You don't need to add nesting, it's built in to the model. Just add a
text_fieldforcategories_listthat accepts comma-separated values and you'll be good to go. -
Hello mbleigh,
Can you move the gem to gemcutter.org?
http://gems.github.com/ doesn't work anymore :)
Thanks
Comments
I actually already did a couple weeks ago.
gem install acts-as-taggable-on --source http://gemcutter.org -
Tags count column is missing from migration which breaks count methods
1 comment Created 3 months ago by bgilesAs pointed out by Stuart Henry https://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on/tickets/49-add-count-column-to-tags-table#ticket-49-2, the count column is not included in acts_as_taggable_on_migration. Consequently, tag counts aren't returned for User.skill_counts, etc.
To fix after the fact create a migration that includes the following:
add_column :tags, :count, :integer, :default => 0Comments
-
when merging conditions string parentheses should be placed around clauses with OR.
Example:currently User.tagged_with("foo, bar", :as => :languages) will result in the following query:
SELECT .... WHERE (context = 'languages' AND users_tags.name LIKE 'foo' OR users_tags.name LIKE 'bar')Note that it will improperly match 'bar' tag in any context.
Comments
-
As shown below, chaining the tagged_with named scope doesn't appear to work, at least not in the way I'm doing it. What nomenclature do I used to find all Products that are tagged with both "081" and "20x24"?
Thanks.
c.>> Product.find(1).tags.map {|t| t.name} => ["081", "20x24", "aluminum", "forever", "frame"] >> Product.tagged_with("081", {}).size => 24 >> Product.tagged_with("20x24", {}).size => 94 >> Product.tagged_with("20x24, 081", {}).size => 118 >> Product.tagged_with("081", {}).tagged_with("20x24", {}).size => 0Comments
As a follow-on, I've figured out how to do what I'm after with find_tagged_with instead of the named scope. There does appear to be a bug in the tagged_with named scope implementation, though.
>> Product.tagged_with("20x24, 081", :match_all => true).size => 118 >> Product.find_tagged_with("20x24, 081", :match_all => true).size => 5Using tagged_with on more than one tag and using :match_all seems to work for me, however, I also need to chain scopes, because I want to use different contexts, for example:
User.tagged_with('technical', :on => :skills).tagged_with('funny', :on => :tags)
But that doesn't work currently... which is a shame. Like your example, it just returns an empty result set.
-
Is the "acts_as_taggable_on: initialized properly" message really needed in the logs?
2 comments Created 6 months ago by dolzenkoSubject :)
Not an issue but really, I have a bunch of other plugins in my vendor folder and acts_as_taggable_on is the only one which proudly announces himself in the logs.
Comments
-
When I run a tag seach with :match_all => true I get the following error.
ActiveRecord::StatementInvalid (PGError: ERROR: column "entries.id" must appear in the GROUP BY clause or be used in an aggregate function : SELECT DISTINCT entries.* FROM "entries" LEFT OUTER JOIN taggings entries_taggings ON entries_taggings.taggable_id = entries.id AND entries_taggings.taggable_type = E'Entry' LEFT OUTER JOIN tags entries_tags ON entries_tags.id = entries_taggings.tag_id WHERE ((context = E'tags' AND entries_tags.name LIKE E'abandoned stairs') AND ("entries"."status" = E'published')) GROUP BY entries_taggings.taggable_id HAVING COUNT(entries_taggings.taggable_id) = 1 ORDER BY published_at DESC LIMIT 30 OFFSET 0):Comments
yep, I'm getting the same thing when deploying on Heroku (postgres) and trying to use find_tagged_with
Processing TagsController#show (for 86.130.208.17 at 2009-07-18 15:26:58) [GET]
Parameters: {"tags"=>["uk"], "action"=>"show", "controller"=>"tags"}ActiveRecord::StatementInvalid (PGError: ERROR: column "links.id" must appear in the GROUP BY clause or be used in an aggregate function
: SELECT DISTINCT links.* FROM "links" LEFT OUTER JOIN taggings links_taggings ON links_taggings.taggable_id = links.id AND links_taggings.taggable_type = E'Link' LEFT OUTER JOIN tags links_tags ON links_tags.id = links_taggings.tag_id WHERE (links_tags.name LIKE E'uk') GROUP BY links_taggings.taggable_id HAVING COUNT(links_taggings.taggable_id) = 1): /home/slugs/29705_7bbcdfd_ee70/mnt/.gems/gems/mbleigh-acts-as-taggable-on-1.0.5/lib/acts_as_taggable_on/acts_as_taggable_on.rb:117:infind_tagged_with' app/controllers/tags_controller.rb:8:inshow'It looks like it is fixed in http://github.com/harleyttd/acts-as-taggable-on/commit/a2a560191792aa0b028f751dc55ddef0da30c696
Postgres support would be welcome.
This commit resolves the problem with PostgreSQL:
http://github.com/morgoth/acts-as-taggable-on/commit/3ad83818ad3c6a5b71d6259a510ec22e8618af3c
I sent pull request.
allaboutruby
Sun Dec 06 05:23:18 -0800 2009
| link
Actually, it doesn't fix it fully. The related_search still doesn't work. To fix it you'll need to change related_search_options method :group to:
:group => "#{column_namer(klass)}",And add a new method:
def column_namer(klass) klass.column_names.map { |column| "#{klass.table_name}.#{column}" }.join(", ") endOk, so I fixed this in commit: http://github.com/morgoth/acts-as-taggable-on/commit/c8d0da01fc2faf9e09bfc14eda32d8a39ff30c14
I also sent a pull request -
passed-in conditions are not being sanitized, causing some funky behavior with bound parameters; ex: :conditions => [ "foo.id IN (?)", [1,2,3,4,5] ] is being converted to SQL " foo.id in (?) AND 1 AND 2 AND 3 AND 4 AND 5"
here's a fix I applied that appears to be working:
before:
conditions = [
taggable_type, taggable_id, options[:conditions], start_at, end_at ]after:
conditions = [
taggable_type, taggable_id, sanitize_sql(options[:conditions]), start_at, end_at ]Comments
I want to add permalink attribute to tag
{ :select => "#{Tag.table_name}.id, #{Tag.table_name}.name, COUNT(*) AS count",
should be
{ :select => "#{Tag.table_name}.*, COUNT(*) AS count",
-
Hi,
This a great plugin. Here two small bugs.
in : find_options_for_find_tagged_with()
change : conditions << sanitize_sql(["context = ?",on.to_s])
to : conditions << sanitize_sql(["#{Tagging.table_name}.context = ?",on.to_s])in : find_options_for_tag_counts()
change:
{ :select => "#{Tag.table_name}.id, #{Tag.table_name}.name, COUNT(*) AS count",:joins => joins.join(" "), :conditions => conditions, :group => group_by }to :
{ :select => "#{Tag.table_name}.id, #{Tag.table_name}.name, COUNT(*) AS count",:joins => joins.join(" "), :conditions => conditions, :group => group_by, :order => options[:order] }Best regards,
miguel cabero
Comments
forget the first bug correction, here is the right change :
in : find_options_for_find_tagged_with()
change :unless (on = options.delete(:on)).nil?
conditions << sanitize_sql(["#{context = ?",on.to_s]) end
taggings_alias, tags_alias = "#{table_name}taggings", "#{table_name}tags"to :
taggings_alias, tags_alias = "#{table_name}taggings", "#{table_name}tags"
unless (on = options.delete(:on)).nil?
conditions << sanitize_sql(["#{taggings_alias}.context = ?",on.to_s]) end -
If I call tagged_with without specifying options, I get an exception thrown:
ArgumentError: wrong number of arguments (1 for 2)
from vendor/plugins/acts-as-taggable-on/lib/acts_as_taggable_on/acts_as_taggable_on.rb:90I just installed the plugin today; this is a Rails 2.3.2 project.
Here's my proposed patch:
named_scope :tagged_with, lambda{ |tags, *options| options = options.shift || {} find_options_for_find_tagged_with(tags, options) }Comments
Rather, I think a better option could be:
named_scope :tagged_with, lambda{ |*args| find_options_for_find_tagged_with(*args) endSince this has been sitting here for 5 months without a fix, I forked it, adding the fix along with a spec:
http://github.com/skizzybiz/acts-as-taggable-on/
P.S., there are two failing specs, but they were there when I started.






patched on my fork
I've pulled the patch into the main branch and released a new version.