Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7172233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:34:29+00:00 2026-05-28T15:34:29+00:00

The database is seeded with values in english language and format, e.g., :hourlyrate =>

  • 0

The database is seeded with values in english language and format, e.g., :hourlyrate => 20.90. On first start (language is english by default), the input form displays the content of the field correctly. I can modify and save, no problem.
If I switch to german, the number is displayed correctly as 20,90. If I edit anything on this form, I can not save again, as the validation catches the number as not being valid.

My question is, do I have to perform corrections in my controller before saving, or did I miss some built-in function of Rails?

Relevant parts of the code

Helper:

def my_number_with_precision(value)
  if value 
    # value
    number_with_precision(value, :precision => 2)
  end  
end

Validation:

validates :hourlyrate, :numericality => { :greater_or_equal_than => 0, :message => " is an invalid number or below zero" }

Form:

<div class="input">
  <%= f.text_field :hourlyrate, :value => my_number_with_precision(f.object.hourlyrate) %>
</div>

Gemfile

gem 'rails-i18n'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:34:30+00:00Added an answer on May 28, 2026 at 3:34 pm

    I came up with one of the following solutions – language specific code:

    def parse_i18n(value)
      if I18n.locale = 'de' 
        value.gsub(',', '.')
      else
        value
      end
    end
    
    def parse_i18n(value)
      value.gsub(I18n.t("number.currency.format.unit"),'').
            gsub(I18n.t("number.currency.format.delimiter"), '').
            gsub(I18n.t("number.currency.format.separator"), '.') 
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Database setup (MySQL) table: top_fives id, uid, first, second, third, fourth, fifth, creation_date 1,
What database should a beginner use in the C language? Can I use MySQL?
I'm using http://www.phpaes.com/ to encrypt some values and store them in a MySQL database.
Bootstrap executes fine during run-app (database is seeded). But it doesn't appear to get
I have setup EF4.2 (Database First) with my MVC3 site. I have to entities
Database? Page variables? Enum? I'm looking for opinions here.
Database is OracleXE and here is the problem: data gets entered in tables UPS
Database: DB2 v9.5 on AIX Scenario: I have 2 instances- db2inst1 and db2inst2. I
Database has tables Photos and PhotoAlbums. I need a query that will select all
Which Database table Schema is more efficient and why? Users (UserID, UserName, CompamyId) Companies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.