Add_limit (in acts_as_taggable) breaks in 1.1, solution?


#1

Upgraded from Rails 1.0 to 1.1 and found that the (slightly modified)
acts_as_taggable plugin breaks. The line

add_limit!(sql, options)

(in the tags_count method) causes this error

wrong number of arguments (2 for 3)

The documentation still says it takes two args, so I’m not sure what’s
wrong. Adding

logger.info("SQL here: " + sql)
logger.info(“Options here:” + options.inspect)

before the add_limit! call gives

SQL here:
SELECT tags.id AS id, tags.normalized AS name, COUNT(*) AS count FROM
tags_items, items, tags WHERE tags_items.tag_id = tags.id
AND tags_items.item_id = items.id AND items.user_id = 2 GROUP BY
tags.normalized ORDER BY count DESC

Options here:
{:order=>“count DESC”, :conditions=>[“items.user_id = ?”, 2]}

Anyone have any suggestions for what might be wrong and how to fix it?


Henrik N.


#2

I should probably clarify that the problem mentioned below is with the
“built in” ActiveRecord::Base::add_limit!(), it’s not some
acts_as_taggable specific method.


Henrik N

Henrik N wrote:

Upgraded from Rails 1.0 to 1.1 and found that the (slightly modified)
acts_as_taggable plugin breaks. The line

add_limit!(sql, options)

(in the tags_count method) causes this error

wrong number of arguments (2 for 3)

The documentation still says it takes two args, so I’m not sure what’s
wrong. Adding

logger.info("SQL here: " + sql)
logger.info(“Options here:” + options.inspect)

before the add_limit! call gives

SQL here:
SELECT tags.id AS id, tags.normalized AS name, COUNT(*) AS count FROM
tags_items, items, tags WHERE tags_items.tag_id = tags.id
AND tags_items.item_id = items.id AND items.user_id = 2 GROUP BY
tags.normalized ORDER BY count DESC

Options here:
{:order=>“count DESC”, :conditions=>[“items.user_id = ?”, 2]}

Anyone have any suggestions for what might be wrong and how to fix it?


Henrik N


#3

I apologize for repeatedly replying to my own thread. This is my last
message on the subject; just wanted to say that I solved it, so that
someone else might find the solution here. I traced the problem to the
source and reported it, with a suggested fix:
http://dev.rubyonrails.org/ticket/4456


Henrik N