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

121
Views
Rails API returns numeric as string

In my Rails 6 app I have a sales database with a value column. Since this is a 2 decimal number I changed the type to

change_column :sales, :value, :decimal, precision: 10, scale: 2

This app has an API where I render a sales object to json. When I read this API with my angular object and do:

console.log(typeof this.sale.id)

I get string. And when I log the value I get:

value: "40.0"

Why does this happen? Before, when the columns was simples numeric this did not happen. I know that I can convert the variable in JS to a float but I would like to know the reason and avoid converting the variable type.

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!