lundi 9 juillet 2018

checking to see if checkbox is checked rails

I am trying to create my first rails app from scratch but I don't think I should have used rails for this after all. I have a button that uses a method make_calls and within make calls I have it making a bunch of different calls seperated by sleep statements, however I need these to only execute if the calls_check checkbox is checked. Here is what I have:
In my Controller:

# called from inside make_calls method
def individual_call(to_phone, xml_url)

call = @client.calls.create(
                           url: xml_url,
                           to: to_phone,
                           from: '+13474275841',
                           timeout: 20
                         )
if params[:calls_check] == '1'
    puts call.sid
end


In my View:

<body>
    <div class="buttonDiv w3-display-middle">
         <%= check_box :calls_check, id: "calls_check" %>Make Calls
         <%= button_to "Start Call Sequence", action: "make_calls" %>
    </div>
</body>

But even when the checkbox is unchecked it is still making the calls. Any advice?




Aucun commentaire:

Enregistrer un commentaire