test/dummy/app/models/user.rb in conditional_validation-0.0.5 vs test/dummy/app/models/user.rb in conditional_validation-0.1.0
- old
+ new
@@ -1,9 +1,21 @@
class User < ActiveRecord::Base
- validation_accessor :address_attributes, :other_attributes
+ attr_accessor :flag_name
+ validation_flag :flag_attributes, :other_flag_attributes
+
validates :name, presence: true
- with_options if: :validate_on_address_attributes? do |user|
- user.validates :address, presence: true
- user.validates :city, presence: true
+
+ with_options if: :validate_on_flag_attributes? do |user|
+ user.validates :flag_name, presence: true
+ end
+
+
+ # DEPRECATED
+ attr_accessor :accessor_name
+
+ validation_accessor :accessor_attributes, :other_accessor_attributes
+
+ with_options if: :validate_on_accessor_attributes? do |user|
+ user.validates :accessor_name, presence: true
end
end