Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8600913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:43:25+00:00 2026-06-12T01:43:25+00:00

I have the following controller code: class NodesController < ApplicationController def index @nodes =

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:43:26+00:00Added an answer on June 12, 2026 at 1:43 am
    @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>" }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my controller class have the following code class MyController { def flickrService def
I have a controller class as in the following code segment: @Controller public class
I have the following code in the Controller class and for some reason although
I have the following code in a view: def controller_details(request, object_id): controller = Controller.objects.get(pk=object_id)
I have a rails code that sends emails. Following is in my controller: def
Hi I have the following code: Controller: @Controller public class HelloWorldController { @RequestMapping(/hello) public
I have the following code: public abstract class BaseController : Controller { public IUserService
I have written the following code : @Controller @RequestMapping(/test) public class Home { @RequestMapping(value
I have following code in controller: public ActionResult Index(string date) { var topsong =
I have the following code public class BaseController : Controller { SqlConnection con; DataSet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.