1
class User
include MongoMapper::Document
many :properties
validates_associated :properties
...
end
class Property
include MongoMapper::Document
belongs_to :user
many :services
validates_associated :services
...
end
class Service
include MongoMapper::Document
belongs_to :property
...
end
在控制器:
@property.save #returns false and true as expected
current_user.save #returns always true why?
看來,那它不驗證的屬性模型current_user.save方法。 爲什麼? :(
在我的簡短測試中,'validates_associated'只適用於嵌入式關聯。我正在調查,因爲代碼中爲什麼沒有立即清楚。 –