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 349023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:25:10+00:00 2026-05-12T11:25:10+00:00

How do I change validates_numericality_of :test, :greater_than_or_equal_to=>0 into validate form I tried only character

  • 0

How do I change

validates_numericality_of :test, :greater_than_or_equal_to=>0 

into validate form

I tried only character and nil values. I need to check also it must be greater than 0

validate change_test

def change_test
  if @test.nil?
     errors.add_to_base('Hi Test should be only number')
  end
end

and also I tried like this,

validate change_test

def change_test
  if @test.nil?
     errors.add_to_base('Hi Test should be only number')
  else
    if @test < 0
     errors.add_to_base('The number should be greater than or equal to 0')
    end
  end
end

but it is result in error

Please help to solve this problem

thanks all

  • 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-12T11:25:11+00:00Added an answer on May 12, 2026 at 11:25 am
    1. Give the error message, it’s a lot easier to diagnose the problem.
    2. Use built in validations, learn how to change their messages (:message parameter to validates_numericality_of)
    3. if @test < 0 should rather be if @test.to_i < 0
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

change() function works and detects changes on form elements, but is there a way
how can i change the error message Magento throws after it validates the form?
(Note: I cannot change structure of the XML I receive. I am only able
I need to validate a field called student_id in my rails app. The previous
How can I change the error message of jQuery validation so when it validates
Why isn't my style.css making changes to index.html? Both files validate perfectly. Folder set
The following script works fine: $(#regform).validate().showErrors({username:message}); After I changed the script to the below
Change all links that have an image in it to: javascript(alert(thehref)); eg. <a href=/galleries/anna-leah-111827/image01.html><img
To change Proxy server I have to go to IE->Internet Options->LAN Settings and click
I change schema.yml from time to time and execute: symfony propel:build-all-load but the lib/_model

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.