Lets take this example Model:
class Address < ActiveRecord::Base
attr_accessible :city, :postcode, :street, :number
validates :city, presence: true, size: {minimum: 2}
validates :postcode, presence: true
validates :street, presence: true
validates :number, presence: true
end
Do i have to make all validations for each attribute separate? All attributes here have one common validation presence: true. Can´t I write something like validates * , presence: true
Hope you understand what I mean. There should be a solution, as rails and ruby often talk about the DRY way … 🙂
1 Answer