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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.