Q:

can't convert Array into String - add  tag

I have the following controller code:
class NodesController < ApplicationController

  def index
    @nodes = Node.com_name_scope("27").find(:all, :conditions => ['COMPONENT_NAME LIKE ?', "#{params[:search]}%"])

    respond_to do |format|
      format.js {render :js => @nodes.map { |node|  "<li>#{node.COMPONENT_NAME}</li>"}}
    end
end

When I do:
http://localhost/myproject/nodes.js

I get the following list:
<li>Value A</li>
<li>Value B</li>
<li>Value C</li>
<li>Value D</li>

I would like to insert a <ul> tag at the start and end of the list so that it look as follows:
<ul>
<li>Value A</li>
<li>Value B</li>
<li>Value C</li>
<li>Value D</li>
</ul>

But when I do:
format.js {render :js => "ul" + @nodes.map { |node|  "<li>#{node.COMPONENT_NAME}</li>"}+ "</ul>" }

It is giving me the following error message:
 TypeError in NodesController#index

can't convert Array into String

My question is how do I include the <ul> tag in front and at the end of the list.
Thanks a lot for your help

A:

@nodes.map { |node|  "<li>#{node.COMPONENT_NAME}</li>"}

returns an array of strings, you need to join them in some way before merging them with the string.
format.js { render :js => "<ul>#{@nodes.map { |node|  "<li>#{node.COMPONENT_NAME}</li>"}.join}</ul>" }

