Syntax in calling function of acts_as_taggable_on_steroids

The function looks like this.
I don’t know what how I should fill in the parameters.
tl is an array of tags.

def find_tagged_with(tags, options = {})
tags = Tag.parse(tags) if tags.is_a?(String)
return [] if tags.empty?
tags.map!(&:to_s)

      conditions = sanitize_sql(['tags.name in (?)', tags])
      conditions << "and

#{sanitize_sql(options.delete(:conditions))}" if options[:conditions]

      find(:all, { :select => "DISTINCT #{table_name}.*",
        :joins => "left outer join taggings on taggings.taggable_id

= #{table_name}.#{primary_key} and taggings.taggable_type = ‘#{name}’ "
+
“left outer join tags on tags.id =
taggings.tag_id”,
:conditions => conditions }.merge(options))
end

    # Options:
    #  :start_at - Restrict the tags to those created after a

certain time
# :end_at - Restrict the tags to those created before a certain
time
# :conditions - A piece of SQL conditions to add to the query
# :limit - The maximum number of tags to return
# :order - A piece of SQL to order by. Eg ‘tags.count desc’ or
‘taggings.created_at desc’
# :at_least - Exclude tags with a frequency less than the given
value
# :at_most - Exclude tags with a frequency greater then the
given value

and I tried the following syntax and got…

find_tagged_with(tl,{:limit =5})
SyntaxError: compile error
(irb):40: odd number list for Hash
find_tagged_with(tl,{:limit =5})
^
(irb):40: parse error, unexpected ‘=’, expecting ‘}’
find_tagged_with(tl,{:limit =5})
^
from (irb):40

find_tagged_with(tl,{:limit 5})
SyntaxError: compile error
(irb):41: odd number list for Hash
find_tagged_with(tl,{:limit 5})
^
(irb):41: parse error, unexpected tINTEGER, expecting ‘}’
find_tagged_with(tl,{:limit 5})
^
from (irb):41

find_tagged_with(tl,{:limit})
SyntaxError: compile error
(irb):42: odd number list for Hash
find_tagged_with(tl,{:limit})
^
from (irb):42

find_tagged_with(tl,{:limit[5]})
SyntaxError: compile error
(irb):43: odd number list for Hash
find_tagged_with(tl,{:limit[5]})
^
from (irb):43

Anyone knows what’s the right syntax?

Any reference or suggestions are highly appreciated.

I think your first try was the closest. Try

find_tagged_with tl, :limit => 5

This is short for
find_tagged_with(tl, {:limit => 5})

–Shauna

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs