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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:34:35+00:00 2026-06-17T06:34:35+00:00

0. Essentials Using a Rails form and inputs, how do you concatenate a large

  • 0

0. Essentials

Using a Rails form and inputs, how do you concatenate a large number of text inputs into one string attribute?

e.g. “A” , “B”, “C” are each inputs in a Rails form and they are to be concatenated and read in as :string_field => "ABC"

1. Background

I’m making an application that allows user to make their own crossword puzzles. The puzzles are members of my CrosswordPuzzle class, in which the :letters attribute (a string) describes the layout of letters and black spaces in the puzzle.

For example, a 3×3 puzzle as follows…

FOO
O■U
BAR

… should have a :letters attribute of "FOOO_UBAR" (the string represents the puzzle read left to right, top to bottom).

2. Problem

Users create a puzzle by first specifying a size for the puzzle (row x col). This creates a blank puzzle of that size, with each cell being a blank HTML input element. Users can then type the appropriate letters into the blank cells and construct their puzzle.

What I don’t understand how to do is take all of these separate single-character inputs and have Rails interpret them or change them into a single :letters attribute of the puzzle when I submit the edit form. Also, because the puzzles may be of varying sizes with varying numbers of cells, the answer needs to be scalable such that 100-600 input elements can be read into the single 100-600 character string.

Any help would be much appreciated.

P.S. As this is my first post on StackOverflow I apologize in advance if I’ve made any mistakes. (I checked extensively before to see if similar topics had been covered, but they either haven’t or I’m too unfamiliar with the terminology to recognize them)

  • 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-17T06:34:36+00:00Added an answer on June 17, 2026 at 6:34 am

    Configure your form so that each text input has a name like cell[?] where the ? is a zero based array index. So, cell[0], cell[1], etc. Rails will turn all of those into a single parameter entry cell which will be an array. Then, just join them together.

    Skipping rails… something like this.

    1.8.7 > a = []
     => [] 
    1.8.7 > a[0] = 'f'
     => "f" 
    1.8.7 > a[1] = 'o'
     => "o" 
    1.8.7 > a[2] = 'o'
     => "o" 
    1.8.7 > a[3] = 'o'
     => "o" 
    1.8.7 > a
     => ["f", "o", "o", "o"] 
    1.8.7 > a.join
     => "fooo" 
    1.8.7 > 
    

    Or.. do the same thing, but on the client side using javascript, stuffing the result into a hidden ‘letters’ field and then Rails doesn’t have to do anything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create an API with Rails using BDD with RSpec. Rails
I'm using Ruby on Rails to develop a web application. I have a wiki
I'm using the RESTful authentication Rails plugin for an app I'm developing. I'm having
I'm using active admin for my rails app. I have a customer model which
I'm currently using the awesome attachment-fu plugin for a Rails app, but as a
I'm working on a Rails app, where I'm using page caching to store static
A Ruby on Rails app will have access to a number of images and
I'm using Rails 3.0.9, Ruby 1.9.2, Devise 1.3.4 and has a need in Devise
I'm using Rails 3.0.1, HAML 0.3.22, and Mongrel 1.1.5 (and MongoMapper not AR). I'm
I'm using Chef with Vagrant and would like to build a rails stack with

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.