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

[email protected]

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,

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”>

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

<%= 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…

On 5 June 2015 at 06:15, Komala Tm [email protected] wrote:

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

On 5 June 2015 at 14:32, Komala Tm [email protected] wrote:

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

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