0
如何驗證我的Note
型號有多少個標籤?我的模型目前:如何驗證Ruby on Rails 5中的pg數組長度?
# == Schema Information
#
# Table name: notes
#
# id :integer not null, primary key
# title :text
# body :text
# organization_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# tags :string default([]), is an Array
#
# Note represents a saved Note that belongs to an organization.
class Note < ApplicationRecord
belongs_to :organization
validates :title, :body, presence: true
end
tags
是數據庫中的pg數組。