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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:08:24+00:00 2026-05-24T18:08:24+00:00

This is my model class Product < ActiveRecord::Base validates_presence_of :title, :description, :image_url validates_numericality_of :price

  • 0

This is my model

    class Product < ActiveRecord::Base

      validates_presence_of :title, :description, :image_url
      validates_numericality_of :price
      validate :price_must_be_at_least_a_cent
      validates_uniqueness_of :title
      validates_format_of :image_url,
                          :with => %r{\.(gif|jpg|png)$}i,
                          :message => 'must be a URL for GIF, JPG ' +
                          'or PNG image.(gif|jpg|png)'

      protected
      def price_must_be_at_least_a_cent
      errors.add(:price, 'should be at least 0.01' ) if price.nil? ||
      price < 0.01
      end
    end

It validates all the errors correctly but i get the generic error messages. Here is the screenshot of the error messagesRails Error

What am I doing wrong?

  • 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-24T18:08:25+00:00Added an answer on May 24, 2026 at 6:08 pm

    Uninstall the gem: I18n and see if the message appears fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model associations: class Product < ActiveRecord::Base has_many :prices class Price
I have the following two models: class Product < ActiveRecord::Base belongs_to :shop validates_numericality_of :price,
For example i have this model: class Product < ActiveRecord::Base attr_accessible :name, :order end
I have models like this: class Vendor(models.Model): title = models.CharField() class Product(models.Model): ... vendor
I have this Project model: class Project < ActiveRecord::Base validates :status, :inclusion => {
I have the following models: class Price < ActiveRecord::Base belongs_to :product end class Metric
I have a Product model: class Product < ActiveRecord::Base belongs_to :subcategory define_index do #
I have the following models: class Product < ActiveRecord::Base belongs_to :brand belongs_to :model accepts_nested_attributes_for
I have model with tag context: class Product < ActiveRecord::Base acts_as_taggable_on :categories end I'm
For my form I am using my Product model: class Product < ActiveRecord::Base attr_accessible

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.