我想執行一個Ruby腳本,使用從Ruby on Rails窗體傳遞給它的參數。在軌道上的紅寶石從窗體傳遞參數到紅寶石腳本
這是一個片段從我來自:
<%= 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 %>
< ...這裏更多text_fields ...>
</div>
<div class="actions">
<%= button_to 'Apply Configs', :remote=>"true" %>
</div>
<% end %>
我Ruby腳本的結構如下:
def apply_configs (param1, param2, param3, ..., etc.)
<... ruby code that executes based on the values passed in param1, param2, param3 ...>
end
我單獨測試了這個Ruby腳本,它工作得很好,如果它接收到正確的輸入參數par am1,param2,param3,.. ,,等等
問題是我怎樣才能執行這個Ruby腳本時,單擊「應用配置」按鈕,我怎麼傳遞給它參數Form_Param1,Form_Param2,Form_Param3,。 ..等等被映射到param1,param2,param3,...等等?
接受一些答案。 – Reactormonk 2011-12-22 10:08:41