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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:46:08+00:00 2026-06-06T21:46:08+00:00

I have to submit multiple forms, I followed the advice of this post: How

  • 0

I have to submit multiple forms, I followed the advice of this post: How to submit multiple, duplicate forms from same page in Rails – preferably with one button

Note I’m still quite new to Rails/programming and some of my ways of doing things might not be ideal.

Here’s my view:

 = form_tag ([@event, @registration]) do
    - x.times do
      = render 'multi_form'
    = submit_tag "Submit registrations"

The form (note that there are more fields):

- hidden_field_tag :event_id, :value => @event.id

.control-group
  = label_tag :title
  .controls
    = select("registrations[][title]", :registration, Registration::TITLE)

.control-group
  = label_tag :first_name
  .controls
    = text_field_tag "registrations[][first_name]"

.control-group
  = label_tag :last_name
  .controls
    = text_field_tag "registrations[][last_name]"

.control-group
  = label_tag :email
  .controls
    = text_field_tag "registrations[][email]"

The controller:

  def create
    array_number = 0
    x.times do
      @registration = Registration.new(params[:registrations][array_number])
      @registration.save
      UserMailer.registration_user_notify(@event, @registration).deliver
      array_number = array_number + 1
    end
    respond_to do |format|
      format.html {redirect_to thank_you_event_registrations_path(@event)}
    end
  end

When submitting it seems, to an extent, to be doing the right thing, for one it fires off an email to x unique email addresses, which makes me think that @registration contains the correct details in each loop – it’s not saving to the database however. I can see that all the params are there in the log file, except that :title seems to be doing something bad (see below: but I’ll focus on that later), the main thing I want it to do now is run though each array and save it as a new entry.

The log:

Parameters: {"utf8"=>"â", "authenticity_token"=>"BQXm5fngW27z/3Wxy9qEzu6D8/g9YQIfBL+mFKVplgE=", "event_id"=>"7", "registrations"=>[{"title"=>{"registration"=>"Mrs"}, "first_name"=>"Person", "last_name"=>"One", "email"=>"charl@privatelabel.co.za"...

I’m hoping the info I provided is enough, any advice will be appreciated.

Thanks!

EDIT:

@iblue

It did the trick! It was a validation error and it’s saving everything into different rows. Thank you very much!

One more thing if I may, any idea how the :title form part should be formatted in order to return paramater:

"title"=>"Mrs",

as opposed to:

"registrations"=>[{"title"=>{"registration"=>"Mrs"},

Thanks again!

  • 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-06T21:46:09+00:00Added an answer on June 6, 2026 at 9:46 pm

    You are not checking if @registration.save actually saves the record. It can return true or false. I guess it just silently fails.

    If you use @registration.save!, it wile raise an exception when anything goes wrong. I guess there is some kind of validation error there.

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

Sidebar

Related Questions

I have multiple forms on the same page but I want to submit all
On my page I have multiple forms all the same as this... <form class='bill-upd'>
I have a page with multiple forms that I submit via Ajax POSTs serially.
I have a Django project that, on one page, has multiple forms (in different
How is it possible to have multiple forms on a page with each one
I have some code as such to submit multiple forms on my page at
I have a page with several forms. I am trying to submit one of
function GenKeyForm(FormNum){ document.GenNewKey+FormNum.submit(); } I have multiple forms within a php page. each form
Say if I have multiple forms with multiple submit button in a single page,
I need to be able to have one submit button for multiple forms. I

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.