views:

18

answers:

1

I have the following code:

Tag.find_all_by_company_id(4).each.collect{|tag| tag.name }.join(",")

(Essentially I'm trying to build a JS array of tag names)

When I run this code, I get:

LocalJumpError: no block given
    from (irb):13:in `each'
    from (irb):13

Any ideas?

+2  A: 

I think you don't need the each. You could just replace it with:

Tag.find_all_by_company_id(4).collect{|tag| tag.name }.join(",")

The thing is, in Ruby 1.8.6, each expects a block. It won't return an enumerator.

Geo
François Beausoleil