Skip to main content
4 of 4
added 15 characters in body; edited title
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Rails validating with condition block

Rails AR. validate one field, with 4 validators & 2 condition block

validates :inn,
          presence: { if: -> { user.is_a?(Client) } },
          inn: { if: -> { user.is_a?(Client) } },
          uniqueness: { if: -> { user.is_a?(Client) } },
          absence: { if: -> { user.is_a?(Department) } }

Could I have some tips on refactoring this?