AlsoValidates
An ActiveModel validator that validates associated models, adding any errors on those models back onto the "primary" model.
Installation
Add this line to your application's Gemfile:
gem 'validation_aggregator'
And then execute:
$ bundle
Or install it yourself as:
$ gem install validation_aggregator
Usage
class Beer
include ActiveModel::Validations
validate_presence_of :hops
end
class Belly
include ActiveModel::Validations
validate_presence_of :button
end
class MonsterTruckRally
include ActiveModel::Validations
attr_accessor :beer, :belly
validate_presence_of :truck_count
also_validate :beer, :belly
def initialize(beer, belly)
@beer = beer
@belly = belly
end
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request