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 8406183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:02:06+00:00 2026-06-09T23:02:06+00:00

Extreme Ruby/Rails novice here: I’m trying to link_to a search action for each individual

  • 0

Extreme Ruby/Rails novice here: I’m trying to link_to a search action for each individual post contained in a block:

<% split_tags = post.tags.split(',') %> # returns ["food", "computers", "health"] %>
<p>Keywords: <%= split_tags.each {|tag| link_to(tag, front_search_tag_path(:tag => tag))}) %></p>

but all it returns is Keywords: ["food", "computers", "health"].
Shouldn’t .each iterate over the array and provide a link to each search_tag_path with the tag as a parameter?

  • 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-09T23:02:10+00:00Added an answer on June 9, 2026 at 11:02 pm

    Nope, #each just performs a block, it does not accumulate any data.

    [1, 2, 3].each{ |n| "Link to item #{n}" } #=> [1, 2, 3]
    

    You have two options, use map to accumulate data:

    [1, 2, 3].map{ |n| "Link to item #{n}" }.join("\n") #=> "Link to item 1\nLink to item 2\nLink to item 3"
    

    Or output directly in the block:

    [1, 2, 3].each{ |n| puts "Link to item #{n}" }
    

    Prints:

    Link to item 1
    Link to item 2
    Link to item 3
    

    In your case this would be the following two options. I prefer the latter.

    <p>Keywords: <%=raw split_tags.map{|tag| link_to(tag)}.join %></p>
    
    <p> Keywords:
      <% split_tags.each do |tag| %>
        <%= link_to(tag) %>
      <% end %>
    </p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Extreme Android developer newbie here...well, new to Android development, not development in general. I
Here is part of my code: extern C REGISTRATION_API int extreme(char* lKey) { string
I am trying to do some extreme precise maths calculation of very big/small number.
What I am trying to do is create a game that has an extreme
I am running Ubuntu (64Bit) with Apache 2.2.17, Passenger 3.0.11, Ruby 1.9.3 and Rails
I'm reading an eBook for EXTREME beginners in Ruby. It's walking me through VERY
wiHi everyone since last time i found extreme help on here, im gonna ask
I am an extreme noob with jQuery. I'm trying to show an item based
I'm trying to work my way through Ron Jeffries's Extreme Programming Adventures in C#.
Ok guys, let me preface by saying I'm an extreme novice when it comes

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.