Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5053

Validation Error not working

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.3.0
    • Component/s: Validations
    • None
    • Environment:
      Ubuntu/Ruby on rails/mongoid (7.3.0.alpha ff8fefa)

      Hi 
      I am creating rails app with 
      Rails version: 6.1.3
      Ruby version: 3.0.0
      mongoid: mongoid (7.3.0.alpha ff8fefa)

      When I took gem 'mongoid', '~> 7.2'
      gave me issue of 

      Bundler could not find compatible versions for gem "activemodel":
      In Gemfile:
      mongoid (~> 7.2) x86_64-linux was resolved to 7.2.0, which depends on
      activemodel (>= 5.1, < 6.1)

      rails (~> 6.1.3) x86_64-linux was resolved to 6.1.3, which depends on
      activemodel (= 6.1.3)

      So I have to go for mongoid (7.3.0.alpha ff8fefa)

      When I have added validations to my model

      class Whatsapp
      include Mongoid::Document
      include Mongoid::Timestamps

      field :mobile_number, type: String
      field :message, type: String
      field :api_response, type: String

      validates :mobile_number, :message, :api_response, presence: true
      end

      3.0.0 :001 > w = Whatsapp.create!(mobile_number: "9898989898", message: "", api_response: "")
      Traceback (most recent call last):
      1: from (irb):1:in `<main>'
      ArgumentError (wrong number of arguments (given 3, expected 1..2))

      What is the issue?

        1. article.rb
          0.2 kB
          hanish jadala
        2. articles_controller.rb
          2 kB
          hanish jadala

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            hanishjadala@gmail.com hanish jadala
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: