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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:35:56+00:00 2026-06-15T22:35:56+00:00

This is what I want to build in Ruby on Rails: <tr> <td>attribute0</td> <input

  • 0

This is what I want to build in Ruby on Rails:

<tr>
<td>attribute0</td>
<input name="1" type="radio" value="1" />
<input name="1" type="radio" value="2" />
<input name="1" type="radio" value="3" />
<input name="1" type="radio" value="4" />
<input name="1" type="radio" value="5" />
<td>attribute1</td>
</tr>

the number of the radio buttons should be variable.
I’m using the content_tag method to generate the HTML-tags:

@template.content_tag(:tr, @template.content_tag(:td, ... ))

Is it possible to add statement like

for i in 1..5 do
    @template.tag(:input, :type => 'radio', :value => i, :name => options[:name])
end

as a parameter for content_tag?

  • 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-15T22:35:58+00:00Added an answer on June 15, 2026 at 10:35 pm

    You can pass in a block or use a helper. Here’s an example of a helper method

    def inputs(amount, name)
      [1..amount].inject('') do |html, num| 
        html + tag(:input, type: 'radio', value: num, name: name)
      end
    end
    

    Edit: exmaple of block

    Documentation: http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag

    content_tag :ul do
      5.times.map{ content_tag :li, 'element' }.reduce(&:+)
    end
    
    # same as
    
    elements = 5.times.map{ content_tag :li, 'element' }.reduce(&:+)
    content_tag :ul, elements
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want build a sketch pad app on iPhone, I assume that this type
I built this simple script to input a certain number, Now I want to
I want to build a 2 dimensional (non ragged at this point) object array.
I want to build an android application, this application allow the users to answer
I want to build a simple application with the MVVM pattern. This application will
I want to build nested json object using python jsonpickle, something like this {key:
I want to implement a rspec test for a ruby on rails project. Some
I want to build a rails3 website authed with LDAP, so I chose ruby-ldap
(A while back I read this great post: http://aaronlongwell.com/2009/06/the-ruby-on-rails-cms-dilemma.html , discussing the Rails CMS
I want to build a company to demonstrate and sell our products. It should

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.