カスタムモデルがあります。データベースなしで動作しており、アクティブなレコードからいくつかの mixin が含まれています。
class Node
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :title, :content
validates_presence_of :title, :content
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
def persisted?
false
end
def save
# we want to run validations here
end
end
グーグルで を使用できることがわかりましたが、その@object.validate
ような方法がないことについて不平を言っています。
助けてください。