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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:36:34+00:00 2026-06-03T17:36:34+00:00

Bassicaly my problem what to do if i have 3 forms and one submit

  • 0

Bassicaly my problem what to do if i have 3 forms and one submit button.

I want to create a form which sends email to each recipient and then create new record in free_registration_coupons table.

I need validation of email for this form.

enter image description here

Model FreeRegistrationCoupon: recipient_email, token, sender_id

For now i have this:

class FreeRegistrationCouponsController < ApplicationController
  def send_invitations
    emails = [params[:recipient_email_1], params[:recipient_email_2], params[:recipient_email_3]]
    emails.reject!{ |e| e.eql?("") }

    if emails.present?
      emails.each do |e|
        FreeRegistrationCoupon.create(:recipient_email => e, :sender_id => current_user.id)
        #MAILER
      end
      redirect_to root_path, :notice => "You just send #{emails.size} invitations!"
    else
      redirect_to(:back)
    end
  end
end


class FreeRegistrationCoupon < ActiveRecord::Base
  before_save :generate_token

  attr_accessor :recipient_email, :sender_id
  validates :recipient_email, :presence => true, :email => true

  def generate_token
    self.token = SecureRandom.hex
  end
end

This is form which is in other controller CarsController#confirm:

<%= form_tag :controller => 'free_registration_coupons', :action => "send_invitations" do %>
  <!-- errors -->
  <%= label_tag :recipient_email_1 %>
  <%= text_field_tag :recipient_email_1 %>
  <%= label_tag :recipient_email_2 %>
  <%= text_field_tag :recipient_email_2 %>
  <%= label_tag :recipient_email_3 %>
  <%= text_field_tag :recipient_email_3 %>
  <%= submit_tag %>
<% end %>
  • 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-03T17:36:35+00:00Added an answer on June 3, 2026 at 5:36 pm

    I think you should have defined your form using:

    <%= form_tag :controller => 'free_registration_coupons', :action => "send_invitations" do %>
      <%= @error_message %>
      <%= label_tag "recipient_email[1]" %>
      <%= text_field_tag "recipient_email[1]" %>
      <%= label_tag "recipient_email[2]" %>
      <%= text_field_tag "recipient_email[2]" %>
      <%= label_tag "recipient_email[3]" %>
      <%= text_field_tag "recipient_email[3]" %>
      <%= submit_tag %>
    <% end %>
    

    This way it will be easier to treat all email address on your controller and you can track those errors to display them afterwards:

    class FreeRegistrationCouponsController < ApplicationController
      def send_invitations
        emails = params[:recipient_email]
        emails.reject!{ |param, value| value.eql?("") }
        errors = []
        if emails.any?
          emails.each do |param, value|
            validation_result = FreeRegistrationCoupon.save(:recipient_email => value, :sender_id => current_user.id)
            #MAILER
          end
          redirect_to root_path, :notice => "You just send #{emails.size} invitations!"
        else
          @error_message = "You have to include, at least, one e-mail address!"
          render :name_of_the_action_that_called_send_invitations      
        end
      end
    end
    

    I didnt test this code. Hope it helps!

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

Sidebar

Related Questions

I am having a problem with Google Chrome. I have a jQuery Registration form:
On one of my websites I have 2 forms on one page, I am
I have a form on my Java application which basically is to provide the
I basically have two forms, one for Male and another for Female. The code
I am having a problem with some bean validation. Basically I have a form
I want to create a javascript form that basically has a bunch of text
In my Windows Forms Application, basically I have two DataGridView s. I want to
I'm not finding any question specifically with the odd problem I have. Basically I've
I have basically the same problem outlined in this question, however I am using
I have a problem with my BroadcastReceiver. Basically, I have a function in my

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.