mardi 3 décembre 2019

"comparison of BigDecimal with nil failed"

I have problem posting banner using postman. It says something like "comparison of BigDecimal with nil failed". Here is my relations/banner.rb. Can anyone help me out.

module Relations
  module Banner
    extend ActiveSupport::Concern

    included do
      has_many :photos, as: :imageable, dependent: :destroy
      belongs_to :banner_price
      belongs_to :user
      belongs_to :post, inverse_of: :banners, optional: true

And my validation/banner.rb

module Validations
  module Banner
    extend ActiveSupport::Concern

    included do
      validates_presence_of(
        :user,
        :photos
      )

      validates(
        :price,
        price: true
      )

And this is my schema file:

  create_table "banner_prices", force: :cascade do |t|
    t.integer "size"
    t.integer "tier"
    t.decimal "price"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "banners", force: :cascade do |t|
    t.bigint "post_id"
    t.bigint "banner_price_id"
    t.integer "occurance", default: 0
    t.decimal "price"
    t.integer "occurance_limit", default: 0
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.integer "user_id"
    t.string "web_link"
    t.string "title"
    t.index ["banner_price_id"], name: "index_banners_on_banner_price_id"
    t.index ["post_id"], name: "index_banners_on_post_id"
  end

Aucun commentaire:

Enregistrer un commentaire