Q: how can you get values from a checkbox_tag to select records in rails 4 I want to be able to look at records from a model (rails 4) and use a checkbox to select which items will be emailed. I am using paperclip attachments although that probably doesn't matter. 
I added a checkbox_tag to my index
 <tbody>
    <% form_tag %>
    <% @documents.each do |document| %>
      <tr>
        <td><%= document.title %></td>
        <td><%= document.doc_file_file_name %> </td>

        <td><%= check_box_tag("to_email[]", 'document.id') %></td>

As I understand it, that should leave me with an array called to_email with the id's of the documents I want to attach to the email.  I have a submit of 
<%= submit_tag "Edit Checked" %>

I know I have some issues with the syntax of the form tag and the submit_tag. I am trying to get the checked items to show up on a view called preview. I have a route set up as
get 'email/preview' => 'documents#email_preview_list_documents', as: 'preview'

If I am getting values into an array via a checkbox, how can I use that to filter the records? 
I added the changes that were selected and am now getting
 NoMethodError in Documents#email_preview_list_documents
Showing C:/Users/cmendla/RubymineProjects/technical_library/app/views/documents/email_preview_list_documents.html.erb where line #9 raised:

undefined method `each' for nil:NilClass
Rails.root: C:/Users/cmendla/RubymineProjects/technical_library

    NoMethodError in Documents#email_preview_list_documents

NoMethodError in Documents#email_preview_list_documents


A: app/controllers/documents_controller.rb
class DocumentsController < ApplicationController  
  def email_preview_list_documents
    # it includes checkbox name into params
    @to_email = params[:to_email]
  end
end

app/view/documents/email_preview_list_documents.html.erb
<ul>
<% @to_email.each do |email| %>
  <li><%= email %></li>
<% end %>
</ul>


A: It seems like you have to determine @documents in your email_preview_list_documents method. Try to do this:
def email_preview_list_documents
  @documents = Document.all
end

I hope this help you.

A: I finally got this working thanks to the replies and some other research. 
In documents/index.html.erb, I added
 <%= form_tag preview_path do %>
. . .
<td><%= check_box_tag "document_ids[]", document.id %></td>
. . . 
<%= submit_tag "Edit Checked" %>

in the documents controller, I added
 def index_multiple
 @documents = Document.find(params[:document_ids])

in routes.rb, I added
 match 'email/preview', to:  'documents#index_multiple', via: [:get, :post ], as: 'preview'

That allows me to look at the index, check the items I want, and then have them display on a new page. The Document.find will compare the ids of the documents with the IDs of the array from the checkboxes and show only those documents that were checked. 
