How to use checkbox in rails views

Hi all,

         I want to know how to use checkbox in rails, i.e. how to
access value of particular checkbox in controller....

Regards,
Kiran

polawarkirand@gmail.com

Hi Kiran,

your view code like this ;-
   <%=check_box_tag('chk_box_name', value = '1', checked = true,
options = {:class=>'class_name'})%>
you can get value in controller like this :-
     variable_name=params[:chk_box_name]

Regards,
Nishant

Hi Everyone,

I would like to know how to use multiple checkboxs in rails, i.e. how
to
access the values of those checked boxes..I have requirement like set of
emails and corresponding checkboxes..whenever u select multiple mails i
need to access of those..

please anyone give solution for this

regards,
komala

Hi Everyone,

I would like to know how to use multiple checkboxs in rails, i.e. how
to
access the values of those checked boxes..I have requirement like set of
emails and corresponding checkboxes..whenever u select multiple mails i
need to access of those..

I asked some questions the first time you asked this, but you did not respond.

Where are you trying to access the values? In the browser or in the
server after posting a form?

You talk about a set of emails, are these records in a table?

Do you have a basic knowledge of Rails, html and javascript or are you
coming at this relatively inexperienced trying to update an existing
app?

Colin

Hi,

I am new to rails.i am taking set of mails from database..my requirment
is
  whenever admin select mails from checkboxes..he need to send mails to
those mailids..i have created controller name newsletters..and in index
i have written this code

able class="table table-striped">
  <thead>
    <tr>
      <th></th>
     <th>Email</th>
      <th>Action</th>
      <!-- <th>Location</th>
      <th>Description</th> -->

  </tr>
  </thead>
  <tbody>
    <% @news.each do |n| %>
    <tr>
       <td><%=check_box_tag('email_ids[]',n.email,options =
{:class=>'NewsLetter'})%></td>
       <td><%=n.email%></td>
        <td><%= link_to 'Delete', n, method: :delete, data: { confirm:
'Are you sure?' } %></td>
      </tr>
<% end %>
  </tbody>
</table>

<%= submit_tag("send") %>
but now i dont know whether i can take those values whenever i ll click
on checkboxes..and how to get those values..how to store it in other
page..here i need to take more than 1 mail id..dont have knowledge about
javascript..please anyone helpme out with the code that what i need to
put it in controller and views..

Firstly I strongly suggest working right through a good tutorial such
as railstutorial.org, including doing all the exercises. That will
give a knowledge of the basics of rails and will allow you to answer
most of your questions yourself.

When you have done that, if you are still having problems then come
back and ask again.

Colin