Can anyone tell me the best way to set a javascript array value to ruby array variable
As I am getting java script array values
$("input[name='entry_ids[]']:Checked").each(function() {
selectedGroups.push($(this).val());
});
How can i set a ruby variable?
Thanks In Advance.
You can’t set ruby variables from JS, JS is a client side programming language therefore the data needs to be sent to your ROR app somehow. If you submit your form as per normal you will have an array of selected values in
params[:entry_ids]. Otherwise, you can use JS to post an AJAX message to your rails action.It doesn’t look like you’re doing anything special though, so I recommend you look at rails forms. If it needs to be asynchronous, use
remote: truein your form helper.