Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
Run a Ruby service inside Javascript inside HTML

I have a view with a simple_form and an input called priority. Before the submit button I have Your request is going to cost $X. My X cost is going to change accordingly to what the user select in the priority input.

The thing is I need to get the priority input from the user to call a Ruby service, get the result and add it to the Your request is going to cost $X.

What I have in my view is something like:

= f.input :priority

p Your request is going to cost <strong id="selected-priority">0</strong>.
= f.submit "Send",
javascript:
   $('#priority').on("change", function(e) {
    var priorityInput = $(this).val(); # this is going to return something like "EMERGENCY"
    var totalInDollars = #{CalculateAmount.call(priority: ??)};
    $('#selected-priority').text("$" + totalInDollars);
  }).change();

This is all working but I have no idea how to add the priorityInput js variable to my service call.

Could someone help? Tks!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!