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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:30:49+00:00 2026-06-09T16:30:49+00:00

My problem is that I don’t have an idea to create a list of

  • 0

My problem is that I don’t have an idea to create a list of users with emails, and in the same list have a checkbox for every user, then at the end have a button ‘Send’ and send all the emails to the checked users, I solved temporaly with:

1)List (index view)

<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Correo</th>
<th>Send Email</th>
<th></th>
<th></th>
<th></th>
 </tr>

<% var1 = []; i = 0 %>

<% @users.each do |user| %>
<tr id=<%= if user.value == 'No dispatched' 
         'c'
       elsif user.value == 'Dispatched'
         'a'
       else
         'b'
       end%> >
<td><%= user.name %></td>
<td><%= user.email %></td>
<td><%= user.value %></td>
<td><% var1[i] = user.name; i=i+1 %>
<%= button_to 'Activate/Desactivate', edit_send_path(user.id), :method => :get %>       </td>
</td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New User', new_user_path %>


<%= button_to 'Send', {:controller => :Send, :action => :send}, :method => :get, :value => 2 %>

2)Send controller

class SendController < ApplicationController



def send
  @users = User.all
  @users.each do |user|
    if user.value == 'In Process'
    UserMailer.registration_confirmation(user).deliver
    user.value = 'Dispatched'
    user.save
end
  end
  redirect_to :controller => :users, :protocol => 'http'
end

def edit
user = User.find(params[:id])
    if user.value == 'In process'
    user.value = 'No dispatched'
    user.save
elsif user.value == 'No dispatched'
    user.value = 'In process'
    user.save
end
  redirect_to :controller => :users, :protocol => 'http'
end

end

I’m using the flag ‘value’ to check if the email was sended

  • 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-09T16:30:50+00:00Added an answer on June 9, 2026 at 4:30 pm

    I did this for part of my senior project, here’s how I did it:

    For each user add a checkbox that is linked to each user’s id inside the do loop, looks like:

    <td><%= check_box_tag ':multiple_users[]', user.id %></td>
    

    Add a submit_tag below the do loop, looks like, note that the name was simply to differentiate between differing actions we used when selecting users:

    <%= submit_tag "Email Selected Users", :name => "selected"  %>
    

    Add the corresponding form tag somewhere at the top of the view, mine goes to the handler, but yours would go to your “send” action, the empty hash is important:

    <%= form_tag handle_checkbox_handler_path({}) do %>
    

    Generate a mailer, I did not do this and I do not know how, I’m sure Google does 🙂 You will also need to make a config file for the mailer (again google this, I can’t help you).

    Once you have that mailer, create an action in it to email a user:

    def email_user(email, subject, text_body)
      @text_body = text_body
      mail( :to => email, :subject => subject, :from => "monkey@feet.com")
    end
    

    Once you have the action, make a corresponding view for the email (mine is very simple it just puts the @text_body value.

    <%= @text_body %>
    

    In your send action send the email to multiple users, here’s my code, I’m no Ruby expert but it worked for me. Also it’s not very clean so I’ll add some comments for your readability:

    if not params[‘:multiple_users’].nil? # There are multiple users to email

        # Split the passed string and loop through each ID in the string sending an email to each user listed
        params[':users'].split.each do |u|
    
          # Emailer is my mailer's name, :subject and :message I passed into the action as well. email_user is the name of my mailer action, defined above.
          Emailer.email_user(User.find(u.to_i).email, params[:subject], params[:message]).deliver
        end
          redirect_to users_path, :notice => "Message was sent successfully"
    
       else # there is only one user to email 
        if Emailer.email_user(params[:email], params[:subject], params[:message]).deliver # Try to send, if fails tell them so
          redirect_to users_path, :notice => "Message was sent successfully"
        else
          redirect_to users_path, :alert => "Message failed to send"
        end
      end
    end
    

    I hope this is readable and at least gives you a starting point. You should also know that the check_box_handler I mentioned earlier does some checking to ensure that nothing bad happened.

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

Sidebar

Related Questions

So I have a problem that I don't really know how to go about.
Let's say we have two concave 2d polygons(A, B), that don't intersect. The problem
i have a problem, that i don't know how to solve it. i have
So, one problem pattern that I keep coming across and don't have a good
I have a problem that I don't know how to solve. I have have
I have a strange problem that I don't understand about DataPager. After changing the
I have a little problem that I don't understand. I have a db that
Quick question, I have a simple javascript problem that I don't know the fix
I have come across a problem that I don't know how to resolve involving
Greetings SO, I have a weird problem that I don't seem to be able

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.