I’m trying to execute a Ruby script that uses parameters passed to it from a Ruby on Rails form.
This is a snippet from my from:
<%= form_for(@test, :html => {:name => "test", :id => "test"}) do |f| %>
<div class="field", id="configure_device">
<%= f.label "Label1" %>
<%= f.text_field :Form_Param1 %>
<%= f.label "Label2" %>
<%= f.text_field :Form_Param2 %>
<%= f.label "Label3" %>
<%= f.text_field :Form_Param3 %>
<… more text_fields here …>
</div>
<div class="actions">
<%= button_to 'Apply Configs', :remote=>"true" %>
</div>
<% end %>
My Ruby script’s structure is as follows:
def apply_configs (param1, param2, param3, ..., etc.)
<... ruby code that executes based on the values passed in param1, param2, param3 ...>
end
I tested this Ruby script separately and it works just fine if it receives the right input parameters param1, param2, param3, ..,, etc.
Te question is how can I execute this Ruby script when the “Apply Configs” button is clicked and how can I pass to it parameters Form_Param1, Form_Param2, Form_Param3, …, etc. to be mapped to param1, param2, param3, …, etc.?
You have to receive it from
params, there are no need ofarguments