У меня есть данные для страны, в которые я хочу отправить значение модельному методу для расчета промежуточного итога по стране. Мне нужно было бы сделать это без того, чтобы пользователь отправлял форму только при выборе страны.
Форма
<%= simple_form_for([@campaign, @order], :html => { :id => "checkout", :class => "form-horizontal" }) do |f| %>
<%= f.input :country, :priority => ['us', 'ca', 'mx', 'gb', 'fr', 'de'], iso_codes: true %>
<p>Display @order.import_tax </p>
<%= f.submit %>
<% end %>
Модель
def import_tax
country // I need this value from the form before submitting so I can perform my calculations
return import_tax_based_on_country
end