I feel like one of the more common use cases for with_options is an :if or an :unless argument to validates, like so:
with_options if: :something? do validates :thing, presence: true validates :other_thing, numericality: { greater_than: 7 } end
``
This breaks down when trying to nest multiple with_options blocks, because the second :if overrides the first when calling Hash#merge. It would be nice if I could do:
with_options if: :something? do validates :thing, presence: true validates :other_thing, presence: true
with_options if: :something_else? do validates :third_thing, presence: true # only runs if something? && something_else? end end
``
Currently to get this to behave as expected I have to do:
with_options if: :something? do validates :thing, presence: true validates :other_thing, presence: true end
with_options if: → { something? && something_else? } do validates :third_thing, presence: true # only runs if something? && something_else? end
``