Forum: Ruby on Rails add_limit (in acts_as_taggable) breaks in 1.1, solution?

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.
4a551074ddba4460f95d011c47190d0e?d=identicon&s=25 Henrik N (Guest)
on 2006-03-28 11:56
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 Nyh
4a551074ddba4460f95d011c47190d0e?d=identicon&s=25 Henrik N (Guest)
on 2006-03-28 15:32
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
4a551074ddba4460f95d011c47190d0e?d=identicon&s=25 Henrik N (Guest)
on 2006-03-28 16:07
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
This topic is locked and can not be replied to.